From 00169bc36156d4a32546229bf39de91213709eaf Mon Sep 17 00:00:00 2001 From: Swat009 Date: Thu, 20 Jun 2019 14:14:02 +0530 Subject: [PATCH] Fixed #30547 -- Doc'd how Meta.constraints affect model validation. --- docs/ref/models/constraints.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt index 6d24f43f673..aaadc78ee94 100644 --- a/docs/ref/models/constraints.txt +++ b/docs/ref/models/constraints.txt @@ -28,6 +28,16 @@ option. (including ``name``) each time. Instead, specify the ``constraints`` option on subclasses directly, providing a unique name for each constraint. +.. admonition:: Validation of Constraints + + In general constraints are **not** checked during ``full_clean()``, and do + not raise ``ValidationError``\s. Rather you'll get a database integrity + error on ``save()``. ``UniqueConstraint``\s are different in this regard, + in that they leverage the existing ``validate_unique()`` logic, and thus + enable two-stage validation. In addition to ``IntegrityError`` on + ``save()``, ``ValidationError`` is also raised during model validation when + the ``UniqueConstraint`` is violated. + ``CheckConstraint`` ===================