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:17 -0400 |
| commit | ced3e303ca6c902c14d08b68806230ce04c71ff7 (patch) | |
| tree | 513eafb0ab0353dfe4cacdb55c502bc2bce5b119 /docs/ref | |
| parent | a2bcec34918ba38a22b46aa5b24317c90fecf0b0 (diff) | |
Fixed #23250 -- Documented that ModelMultipleChoiceField queryset may be None.
Diffstat (limited to 'docs/ref')
| -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 1d8a1c9b5d..b855e2a10d 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -1048,6 +1048,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`` ~~~~~~~~~~~~~~~~~~~~ |
