开发者

Django auth.User in Admininterface: coercing to Unicode: need string or buffer, User found

I'm pretty new to django. I try to use the auth.User object as a foreign key.

My model:

from django.contrib.auth.models import User

(...)

class Entry(models.Model):
    (...)
    user = models.ForeignKey(User)
    date = models.DateTimeField()
    def __unicode__(self):
        return self.user

When creating a new Entry with a user in admin interface, i get: "coercing to Unicode: need string or buffer, User found"

Exception Type: T开发者_如何学编程ypeError

Exception Value: coercing to Unicode: need string or buffer, User found

Exception Location: /Library/Python/2.7/site-packages/django/utils/encoding.py in force_unicode, line 71

What am i missing?


this should work and explain itself

def __unicode__(self):
    return unicode(self.user)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜