From ea35fb1c54d3f2deb76a31a21314d4b4cc29d177 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Mon, 13 Jun 2011 12:49:09 +0100 Subject: [PATCH] More robust _present_fields additions --- mongoengine/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mongoengine/base.py b/mongoengine/base.py index aed17bc3..592a6784 100644 --- a/mongoengine/base.py +++ b/mongoengine/base.py @@ -91,9 +91,10 @@ class BaseField(object): def __set__(self, instance, value): """Descriptor for assigning a value to a field in a document. """ - instance._data[self.name] = value + key = self.name + instance._data[key] = value # If the field set is in the _present_fields list add it so we can track - if hasattr(instance, '_present_fields') and self.name not in instance._present_fields: + if hasattr(instance, '_present_fields') and key and key not in instance._present_fields: instance._present_fields.append(self.name) def to_python(self, value):