UniCode

For the transition from python 2 to python 3 it is recommended to define a str method and apply a decorator onto the class which will generate the unicode method::

from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible

@python_2_unicode_compatible
class Entry(object):
     ...
    def __str__(self):
        return self.title
     ...

Tags: django models python2 python3

Edit this page
Wiki-logo