Opened 9 years ago
Closed 9 years ago
#24869 closed Bug (needsinfo)
Model unicode and Foreign key
Reported by: | FedorFL | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
possible bug:
class aModel(Model): name = models.CharField(_('name'), null=True, max_length=64, blank=True, default=None) class bModel(Model): aLink = models.ForeignKey(aModel, null=False, blank=False) def __unicode__(self): return u'%s' % (self.aLink.name)
gives error at admin:
RelatedObjectDoesNotExist at ....
bModel has no aLink.
same for
def __unicode__(self): return u'%s' % str(self.id)
but works with
def __unicode__(self): return u'%s' % (self.id.aLink.name)
is it correct?
Change History (2)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Which page gives the error and what is the full traceback?