class documentation

class MultiValueField(Field):

Known subclasses: django.contrib.postgres.forms.ranges.BaseRangeField, django.forms.fields.SplitDateTimeField

View In Hierarchy

Aggregate the logic of multiple Fields.

Its clean() method takes a "decompressed" list of values, which are then cleaned into a single value according to self.fields. Each value in this list is cleaned by the corresponding field -- the first value is cleaned by the first field, the second value is cleaned by the second field, etc. Once all fields are cleaned, the list of clean values is "compressed" into a single value.

Subclasses should not have to implement clean(). Instead, they must implement compress(), which takes a list of valid values and returns a "compressed" version of those values -- a single value.

You'll probably want to use this with MultiWidget.

Method __deepcopy__ Undocumented
Method __init__ Undocumented
Method clean Validate every value in the given list. A value is validated against the corresponding Field in self.fields.
Method compress Return a single value for the given list of values. The values can be assumed to be valid.
Method has​_changed Return True if data differs from initial.
Method validate Undocumented
Class Variable default​_error​_messages Undocumented
Instance Variable fields Undocumented
Instance Variable require​_all​_fields Undocumented

Inherited from Field:

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 get​_bound​_field Return a BoundField instance that will be used when accessing the form field in a template.
Method prepare​_value Undocumented
Method run​_validators Undocumented
Method to​_python 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, fields, *, require_all_fields=True, **kwargs):
def clean(self, value):

Validate every value in the given list. A value is validated against the corresponding Field in self.fields.

For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), clean() would call DateField.clean(value[0]) and TimeField.clean(value[1]).

def compress(self, data_list):

Return a single value for the given list of values. The values can be assumed to be valid.

For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), this might return a datetime object created by combining the date and time in data_list.

def has_changed(self, initial, data):
Return True if data differs from initial.
def validate(self, value):

Undocumented

fields =

Undocumented

require_all_fields =

Undocumented