mirror of
https://github.com/django/django.git
synced 2025-03-26 01:00:46 +00:00
[1.7.x] Fixed #22959 -- Documented that class-based validators need to be deconstructible.
Backport of c692e37b63 from master
This commit is contained in:
parent
cf78a0ccc3
commit
5356183716
@ -37,6 +37,14 @@ use the same validator with forms::
|
|||||||
class MyForm(forms.Form):
|
class MyForm(forms.Form):
|
||||||
even_field = forms.IntegerField(validators=[validate_even])
|
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
|
How validators are run
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user