Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixed #20224 -- Update docs examples which mention __unicode__ #1330

wants to merge 1 commit into


None yet
3 participants

claudep commented Jul 4, 2013

No description provided.

@mjtamlyn mjtamlyn commented on the diff Jul 4, 2013

@@ -124,13 +124,16 @@ Model style
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=40)
+* If you define a ``__str__`` method (previously ``__unicode__`` before Python 3

mjtamlyn Jul 4, 2013


This comment and the one above are worded differently. It would be nice to have consistency.


claudep Jul 4, 2013


Marc, I'm sorry but I'm not getting your idea here.


mjtamlyn Jul 5, 2013


Almost every place in the documentation we say "__unicode__ (or __str__ on Py3)". In this case we mention it the other way around. It's a minor point, and I guess actually as this is in the contributing docs it's a bit different. I hadn't noticed this was in contributing docs earlier which may be a bit different to user facing docs.


mjtamlyn commented Jul 4, 2013

So, when are we dropping 2.7? 😉

@timgraham timgraham commented on the diff Jul 4, 2013

@@ -696,9 +696,9 @@ smoothly:
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 automatically
- converts to the string form of your Python object, you can save yourself
- a lot of work.
+ ``HandField``). So if your ``__unicode__()`` method (``__str__`` on Python 3)

timgraham Jul 4, 2013


add () on str for consistency with "unicode()"

@timgraham timgraham commented on the diff Jul 4, 2013

@@ -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, which entirely obsoletes the ``__unicode__()`` method.

timgraham Jul 4, 2013


I'd replace

", which entirely obsoletes the ``__unicode__()`` method"


"(the __unicode__()`` method is obsolete)"

@timgraham timgraham commented on the diff Jul 4, 2013

@@ -56,9 +58,9 @@ Article objects have access to their related Reporter objects::
>>> r = a.reporter
-These are strings instead of unicode strings because that's what was used in
-the creation of this reporter (and we haven't refreshed the data from the
-database, which always returns unicode strings)::
+On Python 2, these are strings instead of unicode strings because that's what

timgraham Jul 4, 2013


maybe add: strings of type str

@claudep claudep closed this Jul 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment