diff options
| author | Jerin Peter George <jerinpetergeorge@gmail.com> | 2021-01-26 12:05:20 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-01-26 09:31:53 +0100 |
| commit | 1adc09064f88b69b3b565b57502f2a0a32b5f3a8 (patch) | |
| tree | 907674c35f1d0578bb1d805e540d18351bbf9e6b /docs/ref/forms/fields.txt | |
| parent | 42e8cf47c7ee2db238bf91197ea398126c546741 (diff) | |
Fixed #32347 -- Made ModelChoiceField include the value in ValidationError for invalid_choice.
Diffstat (limited to 'docs/ref/forms/fields.txt')
| -rw-r--r-- | docs/ref/forms/fields.txt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index b13af1a270..a4f80831ad 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -1219,6 +1219,9 @@ generating choices. See :ref:`iterating-relationship-choices` for details. * Validates that the given id exists in the queryset. * Error message keys: ``required``, ``invalid_choice`` + The ``invalid_choice`` error message may contain ``%(value)s``, which will + be replaced with the selected choice. + Allows the selection of a single model object, suitable for representing a foreign key. Note that the default widget for ``ModelChoiceField`` becomes impractical when the number of entries increases. You should avoid using it @@ -1307,6 +1310,11 @@ generating choices. See :ref:`iterating-relationship-choices` for details. def label_from_instance(self, obj): return "My Object #%i" % obj.id + .. versionchanged:: 4.0 + + Support for containing ``%(value)s`` in the ``invalid_choice`` error + message was added. + ``ModelMultipleChoiceField`` ---------------------------- |
