Ticket #23250: 23250.diff

File 23250.diff, 984 bytes (added by timgraham, 11 months ago)
  • docs/ref/forms/fields.txt

    diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
    index 1d8a1c9..2ee8dd4 100644
    a b model object (in the case of ``ModelChoiceField``) or multiple model 
    10481048objects (in the case of ``ModelMultipleChoiceField``) into the
    10491049``cleaned_data`` dictionary of the form.
    10501050
     1051For more advanced uses, you can specify ``queryset=None`` when declaring the
     1052form field, and populate the ``queryset`` in the form's ``__init__()`` method::
     1053
     1054    class FooMultipleChoiceForm(forms.Form):
     1055        foo_select = forms.ModelMultipleChoiceField(
     1056            label="Foo Selection",
     1057            help_text="Select a Foo from the choices above.",
     1058            queryset=None,
     1059        )
     1060
     1061        def __init__(self, *args, **kwargs):
     1062            super(FooMultipleChoiceForm, self).__init__(*args, **kwargs)
     1063            self.fields['foo_select'].queryset = ...
     1064
    10511065``ModelChoiceField``
    10521066~~~~~~~~~~~~~~~~~~~~
    10531067
Back to Top