djangodocs.org

1293 sections across all versions Narrow to Django 6.0 (current) →

IntegerField

Reference Form fields

classIntegerField(**kwargs)[source] : - Default widget: NumberInput when Field.localize is False, else TextInput. - Empty value: None - Normalizes to: A Python integer. - Validates that the given value is an integer.

dev

RegexField

Reference Form fields

classRegexField(**kwargs)[source] : - Default widget: TextInput - Empty value: Whatever you’ve given as empty_value. - Normalizes to: A string. - Uses RegexValidator to validate that the given value matches a certain regular expression. - Error message keys: required, invalid

dev

TypedChoiceField

Reference Form fields

classTypedChoiceField(**kwargs)[source] : Just like a ChoiceField, except TypedChoiceField takes two extra arguments, coerce and empty_value.

dev

CharField

Reference Form fields Built-in Field classes

classCharField(**kwargs)[source] : - Default widget: TextInput - Empty value: Whatever you’ve given as empty_value. - Normalizes to: A string. - Uses MaxLengthValidator and MinLengthValidator if max_length and min_length are provided. Otherwise, all inputs are valid.

4.2 5.0 5.1 5.2 6.0

IntegerField

Reference Form fields Built-in Field classes

classIntegerField(**kwargs)[source] : - Default widget: NumberInput when Field.localize is False, else TextInput. - Empty value: None - Normalizes to: A Python integer. - Validates that the given value is an integer.

4.2 5.0 5.1 5.2 6.0

RegexField

Reference Form fields Built-in Field classes

classRegexField(**kwargs)[source] : - Default widget: TextInput - Empty value: Whatever you’ve given as empty_value. - Normalizes to: A string. - Uses RegexValidator to validate that the given value matches a certain regular expression. - Error message keys: required, invalid

4.2 5.0 5.1 5.2 6.0

TypedChoiceField

Reference Form fields Built-in Field classes

classTypedChoiceField(**kwargs)[source] : Just like a ChoiceField, except TypedChoiceField takes two extra arguments, coerce and empty_value.

4.2 5.0 5.1 5.2 6.0

error_messages

Reference Form fields

Field.error_messages The error_messages argument lets you override the default messages that the field will raise. Pass in a dictionary with keys matching the error messages you want to override.

dev

NullBooleanField

Reference Form fields

classNullBooleanField(**kwargs)[source] : - Default widget: NullBooleanSelect - Empty value: None - Normalizes to: A Python True, False or None value. - Validates nothing (i.e., it never raises a ValidationError).

dev

ComboField

Reference Form fields

classComboField(**kwargs)[source] : - Default widget: TextInput - Empty value: '' (an empty string) - Normalizes to: A string. - Validates the given value against each of the fields specified as an argument to the ComboField.

dev

error_messages

Reference Form fields Core field arguments

Field.error_messages The error_messages argument lets you override the default messages that the field will raise. Pass in a dictionary with keys matching the error messages you want to override.

4.2 5.0 5.1 5.2 6.0

ComboField

Reference Form fields Slightly complex built-in Field classes

classComboField(**kwargs)[source] : - Default widget: TextInput - Empty value: '' (an empty string) - Normalizes to: A string. - Validates the given value against each of the fields specified as an argument to the ComboField.

4.2 5.0 5.1 5.2 6.0

MultiValueField

Reference Form fields

classMultiValueField(fields=(),**kwargs)[source] : - Default widget: TextInput - Empty value: '' (an empty string) - Normalizes to: the type returned by the compress method of the subclass.

dev

MultiValueField

Reference Form fields Slightly complex built-in Field classes

classMultiValueField(fields=(),**kwargs)[source] : - Default widget: TextInput - Empty value: '' (an empty string) - Normalizes to: the type returned by the compress method of the subclass.

4.2 5.0 5.1 5.2 6.0

JSONField

Reference Form fields

classJSONField(encoder=None,decoder=None,**kwargs)[source] : A field which accepts JSON encoded data for a JSONField.

dev

JSONField

Reference Form fields Built-in Field classes

classJSONField(encoder=None,decoder=None,**kwargs)[source] : A field which accepts JSON encoded data for a JSONField.

4.2 5.0 5.1 5.2 6.0

Topic guide Formsets Formset validation

You may have noticed the additional data (form-TOTAL_FORMS, form-INITIAL_FORMS) that was required in the formset’s data above. This data is required for the ManagementForm.

4.2 5.0 5.1 5.2 6.0

error_messages

Topic guide Formsets Formset validation

The error_messages argument lets you override the default messages that the formset will raise. Pass in a dictionary with keys matching the error messages you want to override. Error message keys include 'too_few_forms', 'too_many_forms', and 'missing_management_form'.

4.2 5.0 5.1 5.2 6.0