ok,
thank you very much for that. :)
My goal is to update my document from fields validated form (Django).
So if I add a field in my form and in my model, I do not need to touch the code that is responsible for modifying the document Mongo.your method works well :)
i have added this in my model:
def update_from_form( self,cleaned_data ):
"""
Update document, from POST data filtered .
:param cleaned_data: Dictionnaire filtré, renvoyé par le formulaire
"""
for k, v in cleaned_data.items():
if k == '_id' : continue
field = self._fields[k]
if isinstance(field, ReferenceField):
v = DBRef(field.document_type._get_collection_name(), ObjectId(v))
setattr(self, k, v)
return self
thank you again.
Ch.
Le mercredi 10 juillet 2013 17:20:43 UTC+2, christophe de saint leger a écrit :