Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.7.x] Fixed #23354 -- Documented that ModelChoiceField to_field_nam…

…e should be a unique field.

Thanks Keryn Knight for the suggestion.

Backport of 83762da from master
  • Loading branch information...
commit e86030b3be2ac9af4a2855d88802c0b750152c8a 1 parent 307eef2
@timgraham timgraham authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 docs/ref/forms/fields.txt
View
6 docs/ref/forms/fields.txt
@@ -1061,8 +1061,10 @@ method::
.. attribute:: to_field_name
This optional argument is used to specify the field to use as the value
- of the choices in the field's widget. By default it is set to ``None``,
- in which case the primary key of each object will be used. For example::
+ of the choices in the field's widget. Be sure it's a unique field for
+ the model, otherwise the selected value could match more than one
+ object. By default it is set to ``None``, in which case the primary key
+ of each object will be used. For example::
# No custom to_field_name
field1 = forms.ModelChoiceField(queryset=...)
Please sign in to comment.
Something went wrong with that request. Please try again.