diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2014-09-24 19:08:45 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-09-24 14:33:57 -0400 |
| commit | 5356183716daa88e5c0009b179de55370bd5c5da (patch) | |
| tree | 8b48b3b938c5951ef239ca739a26bf969fff6360 /docs | |
| parent | cf78a0ccc39902f73a1e1540b59c3b6c89aa51f6 (diff) | |
[1.7.x] Fixed #22959 -- Documented that class-based validators need to be deconstructible.
Backport of c692e37b63 from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/validators.txt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index 5d8769f950..5672200d7f 100644 --- a/docs/ref/validators.txt +++ b/docs/ref/validators.txt @@ -37,6 +37,14 @@ use the same validator with forms:: class MyForm(forms.Form): even_field = forms.IntegerField(validators=[validate_even]) +You can also use a class with a ``__call__()`` method for more complex or +configurable validators. :class:`RegexValidator`, for example, uses this +technique. If a class-based validator is used in the +:attr:`~django.db.models.Field.validators` model field option, you should make +sure it is :ref:`serializable by the migration framework +<migration-serializing>` by adding :ref:`deconstruct() +<custom-deconstruct-method>` and ``__eq__()`` methods. + How validators are run ====================== |
