From 8a679386c3924026f8558f9cd0164890a9461e2c Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 3 Jul 2013 08:44:03 -0400 Subject: [PATCH] Fixed #20691 -- Added a note for __str__() vs. __unicode__() and Python 3. Thanks garrison for the suggestion. --- docs/ref/unicode.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/ref/unicode.txt b/docs/ref/unicode.txt index e5074285e4..c9534c12c9 100644 --- a/docs/ref/unicode.txt +++ b/docs/ref/unicode.txt @@ -240,6 +240,13 @@ Django will convert it to Unicode when it needs to. Choosing between ``__str__()`` and ``__unicode__()`` ---------------------------------------------------- +.. note:: + + If you are on Python 3, you can skip this section because you'll always + create ``__str__()`` rather than ``__unicode__()``. If you'd like + compatibility with Python 2, you can decorate your model class with + :func:`~django.utils.encoding.python_2_unicode_compatible`. + One consequence of using Unicode by default is that you have to take some care when printing data from the model.