mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #20224 -- Update docs examples which mention __unicode__
Thanks Marc Tamlyn and Tim Graham for the review.
This commit is contained in:
parent
577b0f9189
commit
7442eb1a24
24 changed files with 65 additions and 24 deletions
|
@ -1000,12 +1000,12 @@ objects (in the case of ``ModelMultipleChoiceField``) into the
|
|||
initial value, no empty choice is created (regardless of the value
|
||||
of ``empty_label``).
|
||||
|
||||
The ``__unicode__`` method of the model will be called to generate
|
||||
string representations of the objects for use in the field's choices;
|
||||
to provide customized representations, subclass ``ModelChoiceField``
|
||||
and override ``label_from_instance``. This method will receive a model
|
||||
object, and should return a string suitable for representing it. For
|
||||
example::
|
||||
The ``__unicode__`` (``__str__`` on Python 3) method of the model will be
|
||||
called to generate string representations of the objects for use in the
|
||||
field's choices; to provide customized representations, subclass
|
||||
``ModelChoiceField`` and override ``label_from_instance``. This method will
|
||||
receive a model object, and should return a string suitable for representing
|
||||
it. For example::
|
||||
|
||||
from django.forms import ModelChoiceField
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue