diff options
| author | Tim Graham <timograham@gmail.com> | 2014-08-26 13:52:20 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-08-26 14:50:42 -0400 |
| commit | 8e77ac634ffcbeab634aa8c3f1bda7e6fab229a0 (patch) | |
| tree | 5279aba6933055e3763770ffcbb0bde0337fe27f /docs | |
| parent | adb0c535a9015002e7ec0b58f2c5a6ff1ca054b2 (diff) | |
[1.6.x] Fixed #23250 -- Documented that ModelMultipleChoiceField queryset may be None.
Backport of ced3e303ca from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/forms/fields.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index f6d31f49d2..e3f592b181 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -956,6 +956,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`` ~~~~~~~~~~~~~~~~~~~~ |
