Opened 8 years ago
Closed 8 years ago
#27599 closed Bug (fixed)
str(models.Field()) crashes
Reported by: | Sergey Fedoseev | Owned by: | Morgan Aubert |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
In [1]: from django.db.models import Field In [2]: str(Field()) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-2-4740ae05790d> in <module>() ----> 1 str(Field()) /home/sergey/dev/django/django/utils/six.pyc in <lambda>(self) 840 klass.__name__) 841 klass.__unicode__ = klass.__str__ --> 842 klass.__str__ = lambda self: self.__unicode__().encode('utf-8') 843 return klass 844 /home/sergey/dev/django/django/db/models/fields/__init__.pyc in __str__(self) 188 def __str__(self): 189 """ Return "app_label.model_label.field_name". """ --> 190 model = self.model 191 app = model._meta.app_label 192 return '%s.%s.%s' % (app, model._meta.object_name, self.name) AttributeError: 'Field' object has no attribute 'model'
Change History (5)
follow-up: 3 comment:1 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 8 years ago
Summary: | str(Field()) crashes → str(models.Field()) crashes |
---|
comment:3 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
We could return
super()
for fields not attached to models
It seems like the right thing to do.
Note:
See TracTickets
for help on using tickets.
We could return
super()
for fields not attached to models -- do you have any other idea in mind?