1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

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

@@ -65,7 +65,7 @@ of using ``ogrinspect`` :ref:`in the tutorial <ogrinspect-intro>`.
.. django-admin-option:: --name-field <name_field>
Generates a ``__unicode__`` routine (``__str__`` on Python 3) on the model
Generates a ``__str__`` routine (``__unicode__`` on Python 2) on the model
that will return the given field name.
.. django-admin-option:: --no-imports

View File

@@ -61,8 +61,7 @@ Example
poly = models.PolygonField(srid=4269) # we want our model in a different SRID
objects = models.GeoManager()
# On Python 3: def __str__(self):
def __unicode__(self):
def __str__(self): # __unicode__ on Python 2
return 'Name: %s' % self.name
3. Use :class:`LayerMapping` to extract all the features and place them in the

View File

@@ -244,8 +244,7 @@ model to represent this data::
objects = models.GeoManager()
# Returns the string representation of the model.
# On Python 3: def __str__(self):
def __unicode__(self):
def __str__(self): # __unicode__ on Python 2
return self.name
Please note two important things: