mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-04-10 23:00:58 +00:00
Handle API change in DeferredAttribute descriptor in django-trunk.
This should maintain compatibility with the next version of django.
This commit is contained in:
parent
a84c3afddd
commit
15f9393bb2
2 changed files with 9 additions and 2 deletions
|
|
@ -187,7 +187,10 @@ class FieldInstanceTracker(object):
|
|||
field_tracker = FileDescriptorTracker(field_obj.field)
|
||||
setattr(self.instance.__class__, field, field_tracker)
|
||||
else:
|
||||
field_tracker = DeferredAttributeTracker(field, type(self.instance))
|
||||
if django.VERSION < (2, 1):
|
||||
field_tracker = DeferredAttributeTracker(field, type(self.instance))
|
||||
else:
|
||||
field_tracker = DeferredAttributeTracker(field)
|
||||
setattr(self.instance.__class__, field, field_tracker)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import django
|
||||
from django.db import models
|
||||
from django.db.models.query_utils import DeferredAttribute
|
||||
from django.db.models import Manager
|
||||
|
|
@ -346,7 +347,10 @@ class StringyDescriptor(object):
|
|||
return self
|
||||
if self.name in obj.get_deferred_fields():
|
||||
# This queries the database, and sets the value on the instance.
|
||||
DeferredAttribute(field_name=self.name, model=cls).__get__(obj, cls)
|
||||
if django.VERSION < (2, 1):
|
||||
DeferredAttribute(field_name=self.name, model=cls).__get__(obj, cls)
|
||||
else:
|
||||
DeferredAttribute(field_name=self.name).__get__(obj, cls)
|
||||
return str(obj.__dict__[self.name])
|
||||
|
||||
def __set__(self, obj, value):
|
||||
|
|
|
|||
Loading…
Reference in a new issue