Ticket #5989: subclassing.patch

File subclassing.patch, 1.3 KB (added by Luper Rouch, 17 years ago)
  • django/db/models/fields/subclassing.py

     
    2828    def __get__(self, obj, type=None):
    2929        if obj is None:
    3030            raise AttributeError('Can only be accessed via an instance.')
    31         return self.value
     31        return obj.__dict__[self.field.name]       
    3232
    3333    def __set__(self, obj, value):
    34         self.value = self.field.to_python(value)
     34        obj.__dict__[self.field.name] = self.field.to_python(value)
    3535
    3636def make_contrib(func=None):
    3737    """
  • tests/modeltests/field_subclassing/models.py

     
    103103>>> obj = list(serializers.deserialize("json", stream))[0]
    104104>>> obj.object == m
    105105True
     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)
     11412
     11523
    106116"""}
Back to Top