Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 260f9c51127702afcb1d2c669e0ec1855bdea58c 1 parent 0cae3d5
@malcolmt malcolmt authored
View
4 django/db/models/fields/subclassing.py
@@ -28,10 +28,10 @@ def __init__(self, field):
def __get__(self, obj, type=None):
if obj is None:
raise AttributeError('Can only be accessed via an instance.')
- return self.value
+ return obj.__dict__[self.field.name]
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):
"""
View
10 tests/modeltests/field_subclassing/models.py
@@ -103,4 +103,14 @@ def __unicode__(self):
>>> obj = list(serializers.deserialize("json", stream))[0]
>>> obj.object == m
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
"""}
Please sign in to comment.
Something went wrong with that request. Please try again.