diff options
Diffstat (limited to 'docs/ref/forms')
| -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`` ~~~~~~~~~~~~~~~~~~~~ |
