class documentation

class ModelChoiceField(ChoiceField):

Known subclasses: django.forms.models.ModelMultipleChoiceField

View In Hierarchy

A ChoiceField whose choices are a model QuerySet.
Method __deepcopy__ Undocumented
Method __init__ Undocumented
Method ​_get​_choices Undocumented
Method ​_get​_queryset Undocumented
Method ​_set​_queryset Undocumented
Method get​_limit​_choices​_to Return limit_choices_to for this form field.
Method has​_changed Return True if data differs from initial.
Method label​_from​_instance Convert objects into strings and generate the labels for the choices presented by this object. Subclasses can override this method to customize the display of the choices.
Method prepare​_value Undocumented
Method to​_python Return a string.
Method validate Validate that the input is in self.choices.
Class Variable choices Undocumented
Class Variable default​_error​_messages Undocumented
Instance Variable ​_queryset Undocumented
Instance Variable empty​_label Undocumented
Instance Variable limit​_choices​_to Undocumented
Instance Variable queryset Undocumented
Instance Variable to​_field​_name Undocumented

Inherited from ChoiceField:

Method ​_set​_choices Undocumented
Method valid​_value Check to see if the provided value is a valid choice.
Instance Variable ​_choices Undocumented

Inherited from Field (via ChoiceField):

Method bound​_data Return the value that should be shown for this field on render of a bound form, given the submitted POST data for the field and the initial data, if any.
Method clean Validate the given value and return its "cleaned" value as an appropriate Python object. Raise ValidationError for any errors.
Method get​_bound​_field Return a BoundField instance that will be used when accessing the form field in a template.
Method run​_validators Undocumented
Method widget​_attrs Given a Widget instance (not a Widget class), return a dictionary of any HTML attributes that should be added to the Widget, based on this Field.
Class Variable default​_validators Undocumented
Class Variable empty​_values Undocumented
Instance Variable disabled Undocumented
Instance Variable error​_messages Undocumented
Instance Variable help​_text Undocumented
Instance Variable initial Undocumented
Instance Variable label Undocumented
Instance Variable label​_suffix Undocumented
Instance Variable localize Undocumented
Instance Variable required Undocumented
Instance Variable show​_hidden​_initial Undocumented
Instance Variable validators Undocumented
Instance Variable widget Undocumented
def __deepcopy__(self, memo):
def __init__(self, queryset, *, empty_label='---------', required=True, widget=None, label=None, initial=None, help_text='', to_field_name=None, limit_choices_to=None, blank=False, **kwargs):
def _get_choices(self):
def _get_queryset(self):

Undocumented

def _set_queryset(self, queryset):

Undocumented

def get_limit_choices_to(self):

Return limit_choices_to for this form field.

If it is a callable, invoke it and return the result.

def has_changed(self, initial, data):
Return True if data differs from initial.
def label_from_instance(self, obj):
Convert objects into strings and generate the labels for the choices presented by this object. Subclasses can override this method to customize the display of the choices.
def prepare_value(self, value):
def to_python(self, value):
def validate(self, value):
Validate that the input is in self.choices.
choices =
_queryset =

Undocumented

empty_label =

Undocumented

limit_choices_to =

Undocumented

queryset =

Undocumented

to_field_name =

Undocumented