Opened 4 years ago

Closed 4 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


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' % (

gives error at admin:

RelatedObjectDoesNotExist at ....
bModel has no aLink.

same for

        def __unicode__(self):
		return u'%s' % str(

but works with

        def __unicode__(self):
		return u'%s' % (

is it correct?

Change History (2)

comment:1 Changed 4 years ago by Tim Graham

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

comment:2 Changed 4 years ago by Tim Graham

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