Fixed #5989 -- Fixed a problem with values being incorrectly reused by

reference in field subclassing. Thanks, flupke.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6748 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-11-29 19:30:49 +00:00
parent 0cae3d55b6
commit 260f9c5112
2 changed files with 12 additions and 2 deletions

View File

@ -28,10 +28,10 @@ class Creator(object):
def __get__(self, obj, type=None): def __get__(self, obj, type=None):
if obj is None: if obj is None:
raise AttributeError('Can only be accessed via an instance.') raise AttributeError('Can only be accessed via an instance.')
return self.value return obj.__dict__[self.field.name]
def __set__(self, obj, value): def __set__(self, obj, value):
self.value = self.field.to_python(value) obj.__dict__[self.field.name] = self.field.to_python(value)
def make_contrib(func=None): def make_contrib(func=None):
""" """

View File

@ -103,4 +103,14 @@ TypeError: Invalid lookup type: 'lt'
>>> obj = list(serializers.deserialize("json", stream))[0] >>> obj = list(serializers.deserialize("json", stream))[0]
>>> obj.object == m >>> obj.object == m
True True
# Test retrieving custom field data
>>> m.delete()
>>> m1 = MyModel(name="1", data=Small(1, 2))
>>> m1.save()
>>> m2 = MyModel(name="2", data=Small(2, 3))
>>> m2.save()
>>> for m in MyModel.objects.all(): print unicode(m.data)
12
23
"""} """}