python - Django __unicode__ still not work for me -



python - Django __unicode__ still not work for me -

i utilize django1.6 , python2.7, have next in models.py.

class recommend(models.model): id = models.integerfield(primary_key=true) master_id = models.integerfield() movie_id = models.integerfield() enable = models.textfield() # field type guess. class meta: managed = false db_table = 'recommend' def __unicode__(self): homecoming u'%s %s' % (self.id, self.master_id)

however, result still

>>> movies.models import recommend >>> recommend.objects.all() [<recommend: recommend object>] >>>

i've checked django tutorial unicode not working , `__unicode__()` add-on not working in basic poll application in django tutorial, trouble _unicode() method in django, python 2.7__unicode__(self) not working. none did work me.

use this

from __future__ import absolute_import, partition django.db import models django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class recommend(models.model): id = models.integerfield(primary_key=true) master_id = models.integerfield() movie_id = models.integerfield() enable = models.textfield() # field type guess. class meta: managed = false db_table = 'recommend' def __str__(self): homecoming u'%s %s' % (self.id, self.master_id)

may should help

python django unicode

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -