Ticket #5989: subclassing.patch
File subclassing.patch, 1.3 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/subclassing.py
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.value31 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 """ -
tests/modeltests/field_subclassing/models.py
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 """}