djangodocs.org

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

Form widgets

Reference GeoDjango Forms API

GeoDjango form widgets allow you to display and edit geographic data on a visual map. Note that none of the currently available widgets supports 3D geometries, hence geometry fields will fallback using a Textarea widget for such data.

dev

FORM_RENDERER

Reference Settings

Default: 'django.forms.renderers.DjangoTemplates' The default class that renders forms and form widgets. It must implement the low-level render API.

dev

Form submission

Reference Unicode data

HTML form submission is a tricky area. There’s no guarantee that the submission will include encoding information, which means the framework might have to guess at the encoding of submitted data. Django adopts a “lazy” approach to decoding form data.

dev

Topic guide

Form processing generally has 3 paths: Initial GET (blank or prepopulated form) POST with invalid data (typically redisplay form with errors) POST with valid data (process the data and typically redirect) Implementing this yourself often results in a lot of …

dev

Topic guide

Rendering an attractive and easy-to-use web form requires more than just HTML - it also requires CSS stylesheets, and if you want to use fancy widgets, you may also need to include some JavaScript on each page.

dev

Form widgets

Reference GeoDjango Forms API

GeoDjango form widgets allow you to display and edit geographic data on a visual map. Note that none of the currently available widgets supports 3D geometries, hence geometry fields will fallback using a Textarea widget for such data.

4.2 5.0 5.1 5.2 6.0

FORM_RENDERER

Reference Settings Core Settings

Default: 'django.forms.renderers.DjangoTemplates' The class that renders forms and form widgets. It must implement the low-level render API. Included form renderers are: 'django.forms.renderers.DjangoTemplates' 'django.forms.renderers.Jinja2' 'django.forms.renderers.TemplatesSetting'

4.2 5.0 5.1 5.2 6.0

Form submission

Reference Unicode data

HTML form submission is a tricky area. There’s no guarantee that the submission will include encoding information, which means the framework might have to guess at the encoding of submitted data. Django adopts a “lazy” approach to decoding form data.

4.2 5.0 5.1 5.2 6.0

Topic guide

Form processing generally has 3 paths: Initial GET (blank or prepopulated form) POST with invalid data (typically redisplay form with errors) POST with valid data (process the data and typically redirect) Implementing this yourself often results in a lot of …

4.2 5.0 5.1 5.2 6.0

Topic guide

Rendering an attractive and easy-to-use web form requires more than just HTML - it also requires CSS stylesheets, and if you want to use fancy widgets, you may also need to include some JavaScript on each page.

4.2 5.0 5.1 5.2 6.0

Form rendering options

Topic guide Working with forms Working with form templates

There are other output options though for the <label>/<input> pairs: {{ form.as_div }} will render them wrapped in <div> tags. {{ form.as_table }} will render them as table cells wrapped in <tr> tags.

4.2

Inline form events

Reference JavaScript customizations in the admin

You may want to execute some JavaScript when an inline form is added or removed in the admin change form. The formset:added and formset:removed events allow this. event.detail.formsetName is the formset the row belongs to.

dev

Initial form values

Reference The Forms API

Form.initial Use initial to declare the initial value of form fields at runtime. For example, you might want to fill in a username field with the username of the current session.

dev

Model form Meta API

Reference Model forms

classModelFormOptions[source] The _meta API is used to build forms that reflect a Django model. It is accessible through the _meta attribute of each model form, and is a django.forms.models.ModelFormOptions instance.

dev

The form rendering API

Reference

Django’s form widgets are rendered using Django’s template engines system. The form rendering process can be customized at several levels: Widgets can specify custom template names. Forms and widgets can specify custom renderer classes.

dev

Reference The form rendering API

Form templates receive a context from Form.get_context(). By default, forms receive a dictionary with the following values: form: The bound form. fields: All bound fields, except the hidden fields. hidden_fields: All hidden bound fields.

dev