coercing to Unicode: need string or buffer, NoneType found when rendering in django admin

后端 未结 6 627
梦毁少年i
梦毁少年i 2020-12-07 22:32

I have this error since a long time but can\'t figure it out :

Caught TypeError while rendering: coercing to Unicode: need string or buffer, NoneType found

6条回答
  •  执笔经年
    2020-12-07 22:40

    First, check that whatever you are returning via unicode is a String.

    If it is not a string you can change it to a string like this (where self.id is an integer)

    def __unicode__(self):
        return '%s' % self.id
    

    following which, if it still doesn't work, restart your ./manage.py shell for the changes to take effect and try again. It should work.

    Best Regards

提交回复
热议问题