Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Malcolm Tredinnick authored November 29, 2007
4  django/db/models/fields/subclassing.py
@@ -28,10 +28,10 @@ def __init__(self, field):
28 28
     def __get__(self, obj, type=None):
29 29
         if obj is None:
30 30
             raise AttributeError('Can only be accessed via an instance.')
31  
-        return self.value
  31
+        return obj.__dict__[self.field.name]        
32 32
 
33 33
     def __set__(self, obj, value):
34  
-        self.value = self.field.to_python(value)
  34
+        obj.__dict__[self.field.name] = self.field.to_python(value)
35 35
 
36 36
 def make_contrib(func=None):
37 37
     """
10  tests/modeltests/field_subclassing/models.py
@@ -103,4 +103,14 @@ def __unicode__(self):
103 103
 >>> obj = list(serializers.deserialize("json", stream))[0]
104 104
 >>> obj.object == m
105 105
 True
  106
+
  107
+# Test retrieving custom field data
  108
+>>> m.delete()
  109
+>>> m1 = MyModel(name="1", data=Small(1, 2))
  110
+>>> m1.save()
  111
+>>> m2 = MyModel(name="2", data=Small(2, 3))
  112
+>>> m2.save()
  113
+>>> for m in MyModel.objects.all(): print unicode(m.data)
  114
+12
  115
+23
106 116
 """}

0 notes on commit 260f9c5

Please sign in to comment.
Something went wrong with that request. Please try again.