Do not keep calling _dereference on values if it has already been dereferenced.

This commit is contained in:
Gaurav Dadhania
2019-03-25 09:43:42 +05:30
parent 0744892244
commit fdcaca42ae
4 changed files with 111 additions and 1 deletions
+6 -1
View File
@@ -276,11 +276,16 @@ class ComplexBaseField(BaseField):
_dereference = _import_class('DeReference')()
if instance._initialised and dereference and instance._data.get(self.name):
if (instance._initialised and
dereference and
instance._data.get(self.name) and
not getattr(instance._data[self.name], '_dereferenced', False)):
instance._data[self.name] = _dereference(
instance._data.get(self.name), max_depth=1, instance=instance,
name=self.name
)
if hasattr(instance._data[self.name], '_dereferenced'):
instance._data[self.name]._dereferenced = True
value = super(ComplexBaseField, self).__get__(instance, owner)