diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index b9604f5..bcc1f4f 100644
a
|
b
|
class Field(object):
|
444 | 444 | "Returns the value of this field in the given model instance." |
445 | 445 | return getattr(obj, self.attname) |
446 | 446 | |
| 447 | def __repr__(self): |
| 448 | """ |
| 449 | Displays the module, class and name of the field. |
| 450 | """ |
| 451 | name = getattr(self, 'name', None) |
| 452 | if name is not None: |
| 453 | return '<%s.%s %s>' % (self.__class__.__module__, |
| 454 | self.__class__.__name__, |
| 455 | name) |
| 456 | return '<%s.%s>' % (self.__class__.__module__, self.__class__.__name__) |
| 457 | |
447 | 458 | class AutoField(Field): |
448 | 459 | description = _("Integer") |
449 | 460 | |
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index 3ec9d7a..f2a041a 100644
a
|
b
|
class BasicFieldTests(test.TestCase):
|
47 | 47 | nullboolean.full_clean() |
48 | 48 | except ValidationError, e: |
49 | 49 | self.fail("NullBooleanField failed validation with value of None: %s" % e.messages) |
| 50 | |
| 51 | def test_field_repr(self): |
| 52 | """ |
| 53 | Regression test for #5931: __repr__ of a field also displays its name |
| 54 | """ |
| 55 | f = Foo._meta.get_field('a') |
| 56 | self.assertEqual(repr(f), '<django.db.models.fields.CharField a>') |
| 57 | f = models.fields.CharField() |
| 58 | self.assertEqual(repr(f), '<django.db.models.fields.CharField>') |
50 | 59 | |
51 | 60 | class DecimalFieldTests(test.TestCase): |
52 | 61 | def test_to_python(self): |