diff options
| author | Tim Graham <timograham@gmail.com> | 2014-08-27 07:43:13 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-08-27 07:45:34 -0400 |
| commit | e86030b3be2ac9af4a2855d88802c0b750152c8a (patch) | |
| tree | a7e85ae46ac3cde52c40800ee75eec80f79bfc27 | |
| parent | 307eef20e35e78b1e812dc347c6c959e380267cf (diff) | |
[1.7.x] Fixed #23354 -- Documented that ModelChoiceField to_field_name should be a unique field.
Thanks Keryn Knight for the suggestion.
Backport of 83762da3fb from master
| -rw-r--r-- | docs/ref/forms/fields.txt | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 1eeb65261e..0bcbe6c72c 100644 --- a/docs/ref/forms/fields.txt +++ b/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=...) |
