djangodocs.org

694 sections in Django 5.2 Search all versions →

Form.add_error()

Release notes Django 1.7 release notes What’s new in Django 1.7Improvements to Form error handling

Previously there were two main patterns for handling errors in forms: Raising a ValidationError from within certain functions (e.g.

Model validation

Release notes Django 1.2 release notes What’s new in Django 1.2

Model instances now have support for validating their own data, and both model and form fields now accept configurable lists of validators specifying reusable, encapsulated validation behavior. Note, however, that validation must still be performed explicitly.

Forms

Release notes Django 1.10 release notes What’s new in Django 1.10Minor features

Form and widget Media is now served using django.contrib.staticfiles if installed. The <input> tag rendered by CharField now includes a minlength attribute if the field has a min_length. Required form fields now have the required HTML attribute.

Error metadata

Release notes Django 1.7 release notes What’s new in Django 1.7Improvements to Form error handling

The ValidationError constructor accepts metadata such as error code or params which are then available for interpolating into the error message (see Raising ValidationError for more details); however, before Django 1.7 those metadata were discarded as soon as the errors …

Bugfixes

Release notes Django 1.10.2 release notes

Fixed a crash in MySQL database validation where SELECT @@sql_mode doesn’t return a result (#27180). Allowed combining contrib.postgres.search.SearchQuery with more than one & or | operators (#27143). Disabled system check for URL patterns beginning with a ‘/’ when APPEND_SLASH=False (#27238).

CZBirthNumberField.clean

Release notes Django 1.3 release notes Features deprecated in 1.3

Previously this field’s clean() method accepted a second, gender, argument which allowed stronger validation checks to be made, however since this argument could never actually be passed from the Django form machinery it is now pending deprecation.

Minor features

Release notes Django 1.6 release notes What’s new in Django 1.6

Fields included in the localized_fields list will be localized (by setting localize on the form field). The labels, help_texts and error_messages options may be used to customize the default fields, see Overriding the default fields for details.

Release notes Django 1.7 release notes What’s new in Django 1.7Improvements to Form error handling

Heavy changes to the various error containers were necessary in order to support the features above, specifically Form.errors, django.forms.utils.ErrorList, and the internal storages of ValidationError.

Release notes Archive of security issues Issues under Django’s security process

Potential bypass of validation when uploading multiple files using one form field. Full description Django 4.2 (patch) Django 4.1 (patch) Django 3.2 (patch)

Forms

Release notes Django 4.0 release notes What’s new in Django 4.0Minor features

ModelChoiceField now includes the provided value in the params argument of a raised ValidationError for the invalid_choice error message. This allows custom error messages to use the %(value)s placeholder.

Release notes Django 1.1.4 release notes Backwards incompatible changes

Django includes a CSRF-protection mechanism, which makes use of a token inserted into outgoing forms. Middleware then checks for the token’s presence on form submission, and validates it.