Fixes bug with appending post save - due to lists not being reset

This commit is contained in:
Ross Lawley
2011-06-21 12:34:14 +01:00
parent 08ba51f714
commit 09c32a63ce
2 changed files with 20 additions and 3 deletions

View File

@@ -161,7 +161,18 @@ class Document(BaseDocument):
raise OperationError(message % unicode(err))
id_field = self._meta['id_field']
self[id_field] = self._fields[id_field].to_python(object_id)
self._changed_fields = []
def reset_changed_fields(doc):
"""Loop through and reset changed fields lists"""
if hasattr(doc, '_changed_fields'):
doc._changed_fields = []
for field_name in doc._fields:
field = getattr(doc, field_name)
if hasattr(field, '_changed_fields') and field != doc:
reset_changed_fields(field)
reset_changed_fields(self)
signals.post_save.send(self.__class__, document=self, created=created)
def delete(self, safe=False):