diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-02-19 20:27:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-19 20:27:30 +0100 |
| commit | 65c46d6932c0956d2988d13ec3d9ab3ef9d96d61 (patch) | |
| tree | 5d845071518d30642d239fc894b9682ba1959bb6 /docs | |
| parent | 86493307f97b9795a74227b6af2d59a267160847 (diff) | |
Fixed #35358, Refs #35234 -- Renamed _check() methods to check() for constraints.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/6.0.txt | 3 | ||||
| -rw-r--r-- | docs/topics/checks.txt | 20 |
2 files changed, 14 insertions, 9 deletions
diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt index abc56e6886..aeb38d7874 100644 --- a/docs/releases/6.0.txt +++ b/docs/releases/6.0.txt @@ -177,7 +177,8 @@ Migrations Models ~~~~~~ -* ... +* :doc:`Constraints </ref/models/constraints>` now implement a ``check()`` + method that is already registered with the check framework. Requests and Responses ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/topics/checks.txt b/docs/topics/checks.txt index b0e8c2987f..f936ecb00f 100644 --- a/docs/topics/checks.txt +++ b/docs/topics/checks.txt @@ -130,18 +130,18 @@ The code below is equivalent to the code above:: .. _field-checking: -Field, model, manager, template engine, and database checks ------------------------------------------------------------ +Field, constraint, model, manager, template engine, and database checks +----------------------------------------------------------------------- In some cases, you won't need to register your check function -- you can piggyback on an existing registration. -Fields, models, model managers, template engines, and database backends all -implement a ``check()`` method that is already registered with the check -framework. If you want to add extra checks, you can extend the implementation -on the base class, perform any extra checks you need, and append any messages -to those generated by the base class. It's recommended that you delegate each -check to separate methods. +Fields, constraints, models, model managers, template engines, and database +backends all implement a ``check()`` method that is already registered with the +check framework. If you want to add extra checks, you can extend the +implementation on the base class, perform any extra checks you need, and append +any messages to those generated by the base class. It's recommended that you +delegate each check to separate methods. Consider an example where you are implementing a custom field named ``RangedIntegerField``. This field adds ``min`` and ``max`` arguments to the @@ -195,6 +195,10 @@ the only difference is that the check is a classmethod, not an instance method:: # ... your own checks ... return errors +.. versionchanged:: 6.0 + + In older versions, constraints didn't implement a ``check()`` method. + Writing tests ------------- |
