summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-08-26 13:52:20 -0400
committerTim Graham <timograham@gmail.com>2014-08-26 14:50:37 -0400
commit1b89f976f4919a36c6b70eba428c3a02a94e2822 (patch)
treeb707343c077d30881050b8f579bc485ae9e8d6e3 /docs/ref
parent588afbb2be6cf03afde8e1b17980bea09f54ba9a (diff)
[1.7.x] Fixed #23250 -- Documented that ModelMultipleChoiceField queryset may be None.
Backport of ced3e303ca from master
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/forms/fields.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index b58475013e..1eeb65261e 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -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``
~~~~~~~~~~~~~~~~~~~~