Reference
The Forms API
Outputting forms as HTML
If you render a bound Form object, the act of rendering will automatically run the form’s validation if it hasn’t already happened, and the HTML output will include the validation errors as a <ul class="errorlist">.
5.2
6.0
Reference
The Forms API
Outputting forms as HTML
If you render a bound Form object, the act of rendering will automatically run the form’s validation if it hasn’t already happened, and the HTML output will include the validation errors as a <ul class="errorlist"> near the field.
4.2
5.0
5.1
Release notes
Django version 0.96 release notes
django.newforms is Django’s new form-handling library. It’s a replacement for django.forms, the old form/manipulator/validation framework.
dev
Release notes
Django version 0.96 release notes
What’s new in 0.96?
django.newforms is Django’s new form-handling library. It’s a replacement for django.forms, the old form/manipulator/validation framework.
4.2
5.0
5.1
5.2
6.0
Reference
Form and field validation
in tests) that will not vary with translations: Don’t coerce variables into the message; use placeholders and the params argument of the constructor: Use mapping keys instead of positional formatting.
dev
Reference
Form and field validation
… coerce variables into the message; use placeholders and the params argument of the constructor: Use mapping keys instead of positional formatting. This enables putting the variables in any order or omitting them altogether when rewriting the message: Wrap the message …
4.2
5.0
5.1
5.2
6.0
Reference
Django Exceptions
Django Core Exceptions
exceptionValidationError[source] : The ValidationError exception is raised when data fails form or model field validation. For more information about validation, see Form and Field Validation, Model Field Validation and the Validator Reference.
4.2
5.0
5.1
5.2
6.0
Reference
Django exceptions
exceptionValidationError[source] : The ValidationError exception is raised when data fails form or model field validation. For more information about validation, see Form and Field Validation, Model Field Validation and the Validator Reference.
dev
Reference
Form and field validation
The previous sections explained how validation works in general for forms.
dev
Reference
Form and field validation
The previous sections explained how validation works in general for forms.
4.2
5.0
5.1
5.2
6.0
Reference
Form and field validation
If you detect multiple errors during a cleaning method and wish to signal all of them to the form submitter, it is possible to pass a list of errors to the ValidationError constructor.
dev
Reference
Form and field validation
Django’s form (and model) fields support use of utility functions and classes known as validators.
dev
Reference
Form and field validation
Let’s first create a custom form field that validates its input is a string containing comma-separated email addresses.
dev
Reference
Form and field validation
Continuing on from the previous example, suppose that in our ContactForm, we want to make sure that the recipients field only contains addresses that are @example.com.
dev
Reference
Form and field validation
Suppose we add another requirement to our contact form: if the urgent field is True, the subject must contain "help".
dev
Reference
Form and field validation
Raising ValidationError
If you detect multiple errors during a cleaning method and wish to signal all of them to the form submitter, it is possible to pass a list of errors to the ValidationError constructor.
4.2
5.0
5.1
5.2
6.0
Reference
Form and field validation
Using validation in practice
Django’s form (and model) fields support use of utility functions and classes known as validators.
4.2
5.0
5.1
5.2
6.0
Reference
Form and field validation
Using validation in practice
Let’s first create a custom form field that validates its input is a string containing comma-separated email addresses.
4.2
5.0
5.1
5.2
6.0
Reference
Form and field validation
Using validation in practice
Continuing on from the previous example, suppose that in our ContactForm, we want to make sure that the recipients field only contains addresses that are @example.com.
4.2
5.0
5.1
5.2
6.0
Reference
Form and field validation
Using validation in practice
Suppose we add another requirement to our contact form: if the urgent field is True, the subject must contain "help".
4.2
5.0
5.1
5.2
6.0