djangodocs.org

711 sections in Django dev Search all versions →

TypedMultipleChoiceField

Reference Form fields

classTypedMultipleChoiceField(**kwargs)[source] : Just like a MultipleChoiceField, except TypedMultipleChoiceField takes two extra arguments, coerce and empty_value.

UUIDField

Reference Form fields

classUUIDField(**kwargs)[source] : - Default widget: TextInput - Empty value: None - Normalizes to: A UUID object. - Error message keys: required, invalid

SplitDateTimeField

Reference Form fields

- Validates that the given value is a datetime.datetime or string formatted in a particular datetime format. - Error message keys: required, invalid, invalid_date, invalid_time

ModelMultipleChoiceField

Reference Form fields

classModelMultipleChoiceField(**kwargs)[source] : - Default widget: SelectMultiple - Empty value: An empty QuerySet (self.queryset.none()) - Normalizes to: A QuerySet of model instances. - Validates that every id in the given list of values exists in the queryset.

Reference Form fields

By default, ModelChoiceField and ModelMultipleChoiceField use ModelChoiceIterator to generate their field choices. When iterated, ModelChoiceIterator yields 2-tuple choices containing ModelChoiceIteratorValue instances as the first value element in each choice.

ModelChoiceIterator

Reference Form fields

classModelChoiceIterator(field)[source] : The default class assigned to the iterator attribute of ModelChoiceField and ModelMultipleChoiceField. An iterable that yields 2-tuple choices from the queryset.

extend

Topic guide Form Assets (the Media class)

A boolean defining inheritance behavior for Media declarations. By default, any object using a static Media definition will inherit all the assets associated with the parent widget. This occurs regardless of how the parent defines its own requirements.

Topic guide Form Assets (the Media class)

If you need to perform some more sophisticated manipulation of asset requirements, you can define the media property directly. This is done by defining a widget property that returns an instance of forms.Media.

Paths as strings

Topic guide Form Assets (the Media class)

String paths used to specify assets can be either relative or absolute. If a path starts with /, http:// or https://, it will be interpreted as an absolute path, and left as-is.

Jinja2

Reference The form rendering API

Templates for the built-in widgets are located in django/forms/jinja2 and installed apps can provide templates in a jinja2 directory. To use this backend, all the forms and widgets in your project and its third-party apps must have Jinja2 templates.

Reference The form rendering API

This is a dictionary that contains values like: name value attrs is_hidden template_name Some widgets add further information to the context. For instance, all widgets that subclass Input defines widget['type'] and MultiWidget defines widget['subwidgets'] for looping purposes.