summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-05-03 11:51:37 +0000
committerJannis Leidel <jannis@leidel.info>2011-05-03 11:51:37 +0000
commit48cffd9e459d8aaf9d1afa36f4e07f9624b2c4ad (patch)
tree926bd05f80a3866f8e586f5a0512daad8171fd2e /django
parent18d2f4a81611fa4051ccdcfb9dd443f3a247102e (diff)
Fixed #5931 -- Added __repr__ to db fields. Thanks, Thomas Güttler, emulbreh and magopian.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16145 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/fields/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index b9604f5006..9037265e8b 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -444,6 +444,16 @@ class Field(object):
"Returns the value of this field in the given model instance."
return getattr(obj, self.attname)
+ def __repr__(self):
+ """
+ Displays the module, class and name of the field.
+ """
+ path = '%s.%s' % (self.__class__.__module__, self.__class__.__name__)
+ name = getattr(self, 'name', None)
+ if name is not None:
+ return '<%s: %s>' % (path, name)
+ return '<%s>' % path
+
class AutoField(Field):
description = _("Integer")