djangodocs.org

663 sections in Django 5.0 Search all versions →

Python Module Index

| | | django.contrib.auth | Django's authentication framework. | | | django.contrib.auth.backends | Django's built-in authentication backend classes. | | | django.contrib.auth.forms | | | | django.contrib.auth.hashers | | | | django.contrib.auth.middleware | Authentication middleware.

D

Index

… (GDALBand method) - date - field lookup type - template filter - date_attrs (SplitDateTimeWidget attribute) - date_field (DateMixin attribute) - DATE_FORMAT - setting - date_format (SplitDateTimeWidget attribute) - date_hierarchy (ModelAdmin attribute) - DATE_INPUT_FORMATS - setting - date_joined (models.User attribute) - …

G

Index

… - GDALException - GDALRaster (class in django.contrib.gis.gdal) - generate_filename() (Storage method) - GeneratedField (class in django.db.models) - generic view - generic_inlineformset_factory() (in module django.contrib.contenttypes.forms) - GenericForeignKey (class in django.contrib.contenttypes.fields) - GenericInlineModelAdmin (class in django.contrib.contenttypes.admin) - GenericIPAddressField (class in django.db.models) - …

validators

Reference Form fields Core field arguments

Field.validators The validators argument lets you provide a list of validation functions for this field. See the validators documentation for more information.

Topic guide Formsets Formset validation

BaseFormSet has a couple of methods that are closely related to the ManagementForm, total_form_count and initial_form_count. total_form_count returns the total number of forms in this formset.

empty_form

Topic guide Formsets Formset validation

BaseFormSet provides an additional attribute empty_form which returns a form instance with a prefix of __prefix__ for easier use in dynamic forms with JavaScript.

Built-in Field classes

Reference Form fields

Naturally, the forms library comes with a set of Field classes that represent common validation needs. This section documents each built-in field. For each field, we describe the default widget used if you don’t specify widget.

NullBooleanField

Reference Form fields Built-in Field classes

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

CharField

Reference Form fields Built-in Field classes

classCharField(**kwargs) : - 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.

IntegerField

Reference Form fields Built-in Field classes

classIntegerField(**kwargs) : - 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.

RegexField

Reference Form fields Built-in Field classes

classRegexField(**kwargs) : - 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

TypedChoiceField

Reference Form fields Built-in Field classes

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

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.

ComboField

Reference Form fields Slightly complex built-in Field classes

classComboField(**kwargs) : - 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.

MultiValueField

Reference Form fields Slightly complex built-in Field classes

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

JSONField

Reference Form fields Built-in Field classes

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

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.

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'.