Release notes
Django 2.2.22 release notes
Moreover, the URLField form field which uses URLValidator silently removes newlines and tabs on Python 3.9.5+, so the possibility of newlines entering your data only existed if you are using this validator outside of the form fields.
Release notes
Django 3.1.10 release notes
Moreover, the URLField form field which uses URLValidator silently removes newlines and tabs on Python 3.9.5+, so the possibility of newlines entering your data only existed if you are using this validator outside of the form fields.
Release notes
Django 3.2.2 release notes
Moreover, the URLField form field which uses URLValidator silently removes newlines and tabs on Python 3.9.5+, so the possibility of newlines entering your data only existed if you are using this validator outside of the form fields.
Release notes
Django 1.11 release notes
What’s new in Django 1.11Minor features
… the deprecated password_reset_confirm() function-based view) stores the token in a session and redirects to itself to present the password change form to the user without the token in the URL. update_session_auth_hash() now rotates the session key to allow a password …
Reference
GeoDjango Forms API
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.
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'
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.
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 …
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.
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.
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.
Reference
The Forms API
Outputting forms as HTML
Form.auto_id By default, the form rendering methods include: HTML id attributes on the form elements. The corresponding <label> tags around the labels. An HTML <label> tag designates which label text is associated with which form element.
Reference
Model Form API reference. For introductory material about model forms, see the Creating forms from models topic guide.
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.
Reference
The form rendering API
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.
Reference
The form rendering API
Form.template_name To override form templates, you must use the TemplatesSetting renderer. Then overriding form templates works the same as overriding any other template in your project.
Topic guide
Working with forms
Working with form templates
The HTML output when rendering a form is itself generated via a template. You can control this by creating an appropriate template file and setting a custom FORM_RENDERER to use that form_template_name site-wide.
How-to
How to create custom model fields
Writing a field subclassUseful methods
To customize the form field used by ModelForm, you can override formfield(). The form field class can be specified via the form_class and choices_form_class arguments; the latter is used if the field has choices specified, the former otherwise.