From c692e37b6350171ee2e04b3e7090babf34ac140b Mon Sep 17 00:00:00 2001 From: Markus Holtermann Date: Wed, 24 Sep 2014 19:08:45 +0200 Subject: [PATCH] Fixed #22959 -- Documented that class-based validators need to be deconstructible. --- docs/ref/validators.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index 42fb44b650..260c066151 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 +` by adding :ref:`deconstruct() +` and ``__eq__()`` methods. + How validators are run ======================