django difference between validator and clean_field method

django, django-forms, django-validation, python

Solution

Django will first run the built-in (default) field validators, then your custom field validators (using `validators=[your_validator]` in your models). Then, Django will then execute the `clean()` and `clean<field>()` methods.

The main difference between a `validator` and a `clean_<field>()` method is that the latter is only meant for forms. A `validator` can be used for both your forms and your models (and hence will also be used in e.g. the admin interface).

Also, overriding the `clean_<field>()` method is the recommended way to validate data against items in your database.

More info on https://docs.djangoproject.com/en/1.6/ref/forms/validation/.

Problem

In a `form` in `django`, what is the difference between a `validator` for a field and a `clean_<field>` method for that field?

Original source