djangodocs.org

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

Topic guide Creating forms from models ModelForm

… you can do so by defining the field declaratively and setting its validators parameter: NOTE: When you explicitly instantiate a form field like this, it is important to > understand how ModelForm and regular Form are related. ModelForm is a …

4.2 5.0 5.1 5.2 6.0

Using Django

Topic guide

… Apache and mod_wsgi Get your database running Install the Django code Models and databases Models Making queries Aggregation Search Managers Performing raw SQL queries Database transactions Multiple databases Tablespaces Database access optimization Database instrumentation Fixtures Examples of model relationship API …

4.2 5.0 5.1 5.2 6.0

P

Index

… template tag - partialdef - template tag - PASSWORD - setting - password (models.User attribute) - password_change_done_template (AdminSite attribute) - password_change_form (AdminSite attribute) - password_change_template (AdminSite attribute) - password_changed() (in module django.contrib.auth.password_validation) - PASSWORD_HASHERS - setting - PASSWORD_RESET_TIMEOUT - setting …

N

Index

… - naturaltime - template filter - NEVER (ModelAdmin.ShowFacets attribute) - never_cache() (in module django.views.decorators.cache) - new_file() (FileUploadHandler method) - new_objects (models.BaseModelFormSet attribute) - next_page (LoginView attribute) - (LogoutView attribute) - next_page_number() (Page method) - ngettext() (in module django.utils.translation) - ngettext_lazy() …

Topic guide Models FieldsRelationships

… you are using an intermediate model, you can also query on its attributes: If you need to access a membership’s information you may do so by directly querying the Membership model: Another way to access the same information is by …

4.2 5.0 5.1 5.2 6.0

C

Index

… setting - CACHES-TIMEOUT - setting - CACHES-VERSION - setting - CallbackFilter (class in django.utils.log) - callproc() (CursorWrapper method) - can_delete (BaseFormSet attribute) - (InlineModelAdmin attribute) - can_delete_extra (BaseFormSet attribute) - can_order (BaseFormSet attribute) - capfirst - template filter - captured_kwargs …

U

Index

… urlencode - template filter - urlencode() (in module django.utils.http) - (QueryDict method) - URLField (class in django.db.models) - (class in django.forms) - URLInput (class in django.forms) - urlize - template filter - URLIZE_ASSUME_HTTPS - setting - urlizetrunc - template filter …

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.

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.

4.2 5.0 5.1 5.2 6.0

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.

dev

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.

4.2 5.0 5.1 5.2 6.0

NullBooleanField

Reference Form fields Built-in Field classes

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

4.2 5.0 5.1 5.2 6.0

CharField

Reference Form fields

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.

dev