summaryrefslogtreecommitdiff
path: root/docs/ref/models
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-07-04 15:19:33 +0200
committerClaude Paroz <claude@2xlibre.net>2013-07-05 19:30:08 +0200
commita9dd6221af2148410c8a26dcbafd1ff8cc0fb107 (patch)
treebc246344db3a47a6d2340bb6429bd0dbed0f8d20 /docs/ref/models
parent430aae1b0db9fbcc15415b7bd9a14df1d88359cf (diff)
[1.6.x] Fixed #20224 -- Update docs examples which mention __unicode__
Thanks Marc Tamlyn and Tim Graham for the review. Backport of 7442eb1a24 from master.
Diffstat (limited to 'docs/ref/models')
-rw-r--r--docs/ref/models/instances.txt6
-rw-r--r--docs/ref/models/querysets.txt1
2 files changed, 7 insertions, 0 deletions
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index 17c9aa9fb7..f06866d9a1 100644
--- a/docs/ref/models/instances.txt
+++ b/docs/ref/models/instances.txt
@@ -430,6 +430,12 @@ Other model instance methods
A few object methods have special purposes.
+.. note::
+ On Python 3, as all strings are natively considered Unicode, only use the
+ ``__str__()`` method (the ``__unicode__()`` method is obsolete).
+ If you'd like compatibility with Python 2, you can decorate your model class
+ with :func:`~django.utils.encoding.python_2_unicode_compatible`.
+
``__unicode__``
---------------
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 2db252d006..f9d5d001f8 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -830,6 +830,7 @@ For example, suppose you have these models::
name = models.CharField(max_length=50)
toppings = models.ManyToManyField(Topping)
+ # On Python 3: def __str__(self):
def __unicode__(self):
return u"%s (%s)" % (self.name, u", ".join([topping.name
for topping in self.toppings.all()]))