Loading django/contrib/gis/management/commands/ogrinspect.py +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class Command(LabelCommand): make_option('--multi-geom', action='store_true', dest='multi_geom', default=False, help='Treat the geometry in the data source as a geometry collection.'), make_option('--name-field', dest='name_field', help='Specifies a field name to return for the `__unicode__` function.'), help='Specifies a field name to return for the `__unicode__`/`__str__` function.'), make_option('--no-imports', action='store_false', dest='imports', default=True, help='Do not include `from django.contrib.gis.db import models` ' 'statement.'), Loading django/contrib/gis/utils/ogrinspect.py +3 −2 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ def ogrinspect(*args, **kwargs): `multi_geom` => Boolean (default: False) - specify as multigeometry. `name_field` => String - specifies a field name to return for the `__unicode__` function (which will be generated if specified). `__unicode__`/`__str__` function (which will be generated if specified). `imports` => Boolean (default: True) - set to False to omit the `from django.contrib.gis.db import models` code from the Loading Loading @@ -221,4 +221,5 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non if name_field: yield '' yield ' def __str__(self): return self.%s' % name_field yield ' def __%s__(self): return self.%s' % ( 'str' if six.PY3 else 'unicode', name_field) docs/howto/custom-model-fields.txt +3 −3 Original line number Diff line number Diff line Loading @@ -710,9 +710,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) automatically converts to the string form of your Python object, you can save yourself a lot of work. Writing a ``FileField`` subclass Loading docs/internals/contributing/writing-code/coding-style.txt +4 −1 Original line number Diff line number Diff line Loading @@ -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 was supported), decorate the model class with :func:`~django.utils.encoding.python_2_unicode_compatible`. * The order of model inner classes and standard methods should be as follows (noting that these are not all required): * All database fields * Custom manager attributes * ``class Meta`` * ``def __unicode__()`` * ``def __str__()`` * ``def save()`` * ``def get_absolute_url()`` Loading docs/intro/overview.txt +2 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ the file ``mysite/news/models.py``:: class Reporter(models.Model): full_name = models.CharField(max_length=70) # On Python 3: def __str__(self): def __unicode__(self): return self.full_name Loading @@ -40,6 +41,7 @@ the file ``mysite/news/models.py``:: content = models.TextField() reporter = models.ForeignKey(Reporter) # On Python 3: def __str__(self): def __unicode__(self): return self.headline Loading Loading
django/contrib/gis/management/commands/ogrinspect.py +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class Command(LabelCommand): make_option('--multi-geom', action='store_true', dest='multi_geom', default=False, help='Treat the geometry in the data source as a geometry collection.'), make_option('--name-field', dest='name_field', help='Specifies a field name to return for the `__unicode__` function.'), help='Specifies a field name to return for the `__unicode__`/`__str__` function.'), make_option('--no-imports', action='store_false', dest='imports', default=True, help='Do not include `from django.contrib.gis.db import models` ' 'statement.'), Loading
django/contrib/gis/utils/ogrinspect.py +3 −2 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ def ogrinspect(*args, **kwargs): `multi_geom` => Boolean (default: False) - specify as multigeometry. `name_field` => String - specifies a field name to return for the `__unicode__` function (which will be generated if specified). `__unicode__`/`__str__` function (which will be generated if specified). `imports` => Boolean (default: True) - set to False to omit the `from django.contrib.gis.db import models` code from the Loading Loading @@ -221,4 +221,5 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non if name_field: yield '' yield ' def __str__(self): return self.%s' % name_field yield ' def __%s__(self): return self.%s' % ( 'str' if six.PY3 else 'unicode', name_field)
docs/howto/custom-model-fields.txt +3 −3 Original line number Diff line number Diff line Loading @@ -710,9 +710,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) automatically converts to the string form of your Python object, you can save yourself a lot of work. Writing a ``FileField`` subclass Loading
docs/internals/contributing/writing-code/coding-style.txt +4 −1 Original line number Diff line number Diff line Loading @@ -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 was supported), decorate the model class with :func:`~django.utils.encoding.python_2_unicode_compatible`. * The order of model inner classes and standard methods should be as follows (noting that these are not all required): * All database fields * Custom manager attributes * ``class Meta`` * ``def __unicode__()`` * ``def __str__()`` * ``def save()`` * ``def get_absolute_url()`` Loading
docs/intro/overview.txt +2 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ the file ``mysite/news/models.py``:: class Reporter(models.Model): full_name = models.CharField(max_length=70) # On Python 3: def __str__(self): def __unicode__(self): return self.full_name Loading @@ -40,6 +41,7 @@ the file ``mysite/news/models.py``:: content = models.TextField() reporter = models.ForeignKey(Reporter) # On Python 3: def __str__(self): def __unicode__(self): return self.headline Loading