diff options
| author | Morgan Aubert <morgan@aubert.email> | 2016-12-14 14:04:26 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-12-14 14:04:26 -0500 |
| commit | ef889d5b10c02c8f0c19f7384fbb51d291240bee (patch) | |
| tree | 7bc75a3cabd914ee1dfa0c3c27502484eeb6437f /django/db | |
| parent | 3be2268992767d203159818c5353f959360808a7 (diff) | |
Fixed #27599 -- Fixed Field.__str__() crash for fields not attached to models.
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/models/fields/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 340e6a41b7..f1f68dbe7a 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -186,7 +186,12 @@ class Field(RegisterLookupMixin): self.error_messages = messages def __str__(self): - """ Return "app_label.model_label.field_name". """ + """ + Return "app_label.model_label.field_name" for fields attached to + models. + """ + if not hasattr(self, 'model'): + return super(Field, self).__str__() model = self.model app = model._meta.app_label return '%s.%s.%s' % (app, model._meta.object_name, self.name) |
