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 Tim Graham, 9 years ago

Which page gives the error and what is the full traceback?

comment:2 by Tim Graham, 9 years ago

Resolution: needsinfo
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top