Fixed #14567 -- Made ModelMultipleChoiceField return EmptyQuerySet as empty value

This commit is contained in:
Stephen Burrows 2012-10-03 19:50:12 +03:00 committed by Anssi Kääriäinen
parent d25a599dca
commit 218abcc9e5
6 changed files with 40 additions and 7 deletions

View file

@ -997,13 +997,17 @@ objects (in the case of ``ModelMultipleChoiceField``) into the
.. class:: ModelMultipleChoiceField(**kwargs)
* Default widget: ``SelectMultiple``
* Empty value: ``[]`` (an empty list)
* Normalizes to: A list of model instances.
* Empty value: An empty ``QuerySet`` (self.queryset.none())
* Normalizes to: A ``QuerySet`` of model instances.
* Validates that every id in the given list of values exists in the
queryset.
* Error message keys: ``required``, ``list``, ``invalid_choice``,
``invalid_pk_value``
.. versionchanged:: 1.5
The empty and normalized values were changed to be consistently
``QuerySets`` instead of ``[]`` and ``QuerySet`` respectively.
Allows the selection of one or more model objects, suitable for
representing a many-to-many relation. As with :class:`ModelChoiceField`,
you can use ``label_from_instance`` to customize the object

View file

@ -422,6 +422,9 @@ on the form.
Miscellaneous
~~~~~~~~~~~~~
* :class:`django.forms.ModelMultipleChoiceField` now returns an empty
``QuerySet`` as the empty value instead of an empty list.
* :func:`~django.utils.http.int_to_base36` properly raises a :exc:`TypeError`
instead of :exc:`ValueError` for non-integer inputs.