Ticket #5931: 5931.repr_for_model_fields.diff
File 5931.repr_for_model_fields.diff, 1.3 KB (added by , 15 years ago) |
---|
-
django/db/models/fields/__init__.py
339 339 "Returns the value of this field in the given model instance." 340 340 return getattr(obj, self.attname) 341 341 342 def __repr__(self): 343 return '<%s.%s %s>' % (self.__class__.__module__, self.__class__.__name__, getattr(self, "name", None)) 344 342 345 class AutoField(Field): 343 346 empty_strings_allowed = False 344 347 def __init__(self, *args, **kwargs): -
tests/regressiontests/model_fields/tests.py
144 144 bs = BigS.objects.create(s = 'slug'*50) 145 145 bs = BigS.objects.get(pk=bs.pk) 146 146 self.assertEqual(bs.s, 'slug'*50) 147 148 class FieldReprTests(django.test.TestCase): 149 def test_field_repr(self): 150 f = Foo._meta.get_field('a') 151 self.assertEqual(repr(f), '<django.db.models.fields.CharField a>') 152 f = Bar._meta.get_field('a') 153 self.assertEqual(repr(f), '<django.db.models.fields.related.ForeignKey a>') 154