Topic guide
Form Assets (the Media class)
Assets as a static definition
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.
dev
Topic guide
Form Assets (the Media class)
dev
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.
dev
Topic guide
Form Assets (the Media class)
Assets may also be object-based, using Script or Stylesheet.
dev
Topic guide
Form Assets (the Media class)
If you only want files of a particular type, you can use the subscript operator to filter out a medium of interest.
dev
Topic guide
Form Assets (the Media class)
Media objects can also be added together. When two Media objects are added, the resulting Media object contains the union of the assets specified by both:
dev
Topic guide
Form Assets (the Media class)
The order in which assets are inserted into the DOM is often important. For example, you may have a script that depends on jQuery.
dev
Reference
Form fields
Each Field class constructor takes at least these arguments. Some Field classes take additional, field-specific arguments, but the following should always be accepted:
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Core field arguments
By default this value is set to "django/forms/field.html". Can be changed per field by overriding this attribute or more generally by overriding the default template, see also Overriding built-in field templates.
5.0
5.1
5.2
6.0
Reference
Form fields
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
- Validates that the given value is either a datetime.date, datetime.datetime or string formatted in a particular date format. - Error message keys: required, invalid
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
- Validates that the given value is either a datetime.datetime, datetime.date or string formatted in a particular datetime format. - Error message keys: required, invalid
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
classDurationField(**kwargs)[source] : - Default widget: TextInput - Empty value: None - Normalizes to: A Python timedelta. - Validates that the given value is a string which can be converted into a timedelta. The value must be between datetime.timedelta.min and datetime.timedelta.max.
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
classFilePathField(**kwargs)[source] : - Default widget: Select - Empty value: '' (an empty string) - Normalizes to: A string. - Validates that the selected choice exists in the list of choices. - Error message keys: required, invalid_choice
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
classGenericIPAddressField(**kwargs)[source] : A field containing either an IPv4 or an IPv6 address.
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
classMultipleChoiceField(**kwargs)[source] : - Default widget: SelectMultiple - Empty value: [] (an empty list) - Normalizes to: A list of strings. - Validates that every value in the given list of values exists in the list of choices.
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
- Validates that the given value is either a datetime.time or string formatted in a particular time format. - Error message keys: required, invalid
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
classTypedMultipleChoiceField(**kwargs)[source] : Just like a MultipleChoiceField, except TypedMultipleChoiceField takes two extra arguments, coerce and empty_value.
4.2
5.0
5.1
5.2
6.0
Reference
Form fields
Built-in Field classes
classUUIDField(**kwargs)[source] : - Default widget: TextInput - Empty value: None - Normalizes to: A UUID object. - Error message keys: required, invalid
4.2
5.0
5.1
5.2
6.0