Fixed #21951 -- Updated docs to use __str__ for Python 3

Thanks Tim Graham for the report and recommendations
This commit is contained in:
Alasdair Nicol 2014-02-09 11:38:13 +00:00 committed by Tim Graham
parent c3434fed5b
commit 8aa1efff6d
20 changed files with 71 additions and 72 deletions

View file

@ -817,13 +817,13 @@ smoothly:
a field that's similar to what you want and extend it a little bit,
instead of creating an entirely new field from scratch.
2. Put a ``__str__()`` or ``__unicode__()`` method on the class you're
2. Put a ``__str__()`` (``__unicode__()`` on Python 2) method on the class you're
wrapping up as a field. There are a lot of places where the default
behavior of the field code is to call
:func:`~django.utils.encoding.force_text` on the value. (In our
examples in this document, ``value`` would be a ``Hand`` instance, not a
``HandField``). So if your ``__unicode__()`` method (``__str__()`` on
Python 3) automatically converts to the string form of your Python object,
``HandField``). So if your ``__str__()`` method (``__unicode__()`` on
Python 2) automatically converts to the string form of your Python object,
you can save yourself a lot of work.