Ticket #18717: #18717-deferred_fields_and_descriptors.diff

File #18717-deferred_fields_and_descriptors.diff, 864 bytes (added by German M. Bravo, 12 years ago)
  • django/db/models/query_utils.py

    diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
    index a56ab5c..41a62a4 100644
    a b class DeferredAttribute(object):  
    108108        Deferred loading attributes can be set normally (which means there will
    109109        never be a database lookup involved.
    110110        """
     111        cls = self.model_ref()
     112        for field in cls._meta.fields:
     113            if field.attname == self.field_name:
     114                if hasattr(field, '__set__'):
     115                    field.__set__(instance, value)
     116                    if hasattr(field, '__get__'):
     117                        value = field.__get__(instance, cls)
     118                break
    111119        instance.__dict__[self.field_name] = value
    112120
    113121def select_related_descend(field, restricted, requested, reverse=False):
Back to Top