utils.encoding.python_2_unicode_compatible()

python_2_unicode_compatible() [source]

A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing.

To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class.

doc_Django
2016-10-09 18:40:24
Comments
Leave a Comment

Please login to continue.