[1.7.x] Fixed #23250 -- Documented that ModelMultipleChoiceField queryset may be None.

Backport of ced3e303ca from master
This commit is contained in:
Tim Graham 2014-08-26 13:52:20 -04:00
parent 588afbb2be
commit 1b89f976f4
1 changed files with 11 additions and 0 deletions

View File

@ -1003,6 +1003,17 @@ model object (in the case of ``ModelChoiceField``) or multiple model
objects (in the case of ``ModelMultipleChoiceField``) into the
``cleaned_data`` dictionary of the form.
For more complex uses, you can specify ``queryset=None`` when declaring the
form field and then populate the ``queryset`` in the form's ``__init__()``
method::
class FooMultipleChoiceForm(forms.Form):
foo_select = forms.ModelMultipleChoiceField(queryset=None)
def __init__(self, *args, **kwargs):
super(FooMultipleChoiceForm, self).__init__(*args, **kwargs)
self.fields['foo_select'].queryset = ...
``ModelChoiceField``
~~~~~~~~~~~~~~~~~~~~