Skip to content Skip to sidebar Skip to footer

Django: "Can't Convert 'Name' Object To Str Implicitly" On Saving Object

In Django admin, I have created a Name object with name: 'United Kingdom'. I then create a Nation object with the Name object I've just created, and a path to a flag image. On sav

Solution 1:

Use unicodes in __unicode__() method i.e.

u'Name: ' + self.name

and

u'Nation: ' + self.name

Without unicode in 'Nation: ' + self.name, it will try to get string representation which is not defined for Name object.


Solution 2:

The change that fixed the problem:

'Name: ' + self.name.name

That way I'm correctly referring to the name column in the name table.


Post a Comment for "Django: "Can't Convert 'Name' Object To Str Implicitly" On Saving Object"