summaryrefslogtreecommitdiff
path: root/docs/topics/python3.txt
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-11-19 21:54:19 +0100
committerClaude Paroz <claude@2xlibre.net>2017-01-18 13:44:34 +0100
commitf3c43ad1fd9556f0fd026a5dfa93c67a5cf186ca (patch)
tree65ca40d4527b377845cdd382456383bf97caafa6 /docs/topics/python3.txt
parentd7b9aaa366dd54ecc3142c588162e3adc7c2f7ac (diff)
Refs #23919 -- Removed python_2_unicode_compatible decorator usage
Diffstat (limited to 'docs/topics/python3.txt')
-rw-r--r--docs/topics/python3.txt21
1 files changed, 0 insertions, 21 deletions
diff --git a/docs/topics/python3.txt b/docs/topics/python3.txt
index 9dd4d83732..5b40f57bd3 100644
--- a/docs/topics/python3.txt
+++ b/docs/topics/python3.txt
@@ -148,27 +148,6 @@ In Python 3, there's simply :meth:`~object.__str__`, which must return ``str``
(It is also possible to define :meth:`~object.__bytes__`, but Django applications
have little use for that method, because they hardly ever deal with ``bytes``.)
-Django provides a simple way to define :meth:`~object.__str__` and
-` __unicode__()`_ methods that work on Python 2 and 3: you must
-define a :meth:`~object.__str__` method returning text and to apply the
-:func:`~django.utils.encoding.python_2_unicode_compatible` decorator.
-
-On Python 3, the decorator is a no-op. On Python 2, it defines appropriate
-` __unicode__()`_ and :meth:`~object.__str__` methods (replacing the
-original :meth:`~object.__str__` method in the process). Here's an example::
-
- from __future__ import unicode_literals
- from django.utils.encoding import python_2_unicode_compatible
-
- @python_2_unicode_compatible
- class MyClass(object):
- def __str__(self):
- return "Instance of my class"
-
-This technique is the best match for Django's porting philosophy.
-
-For forwards compatibility, this decorator is available as of Django 1.4.2.
-
Finally, note that :meth:`~object.__repr__` must return a ``str`` on all
versions of Python.