From b69f8eb04cc8762d3dfd5af5ea1fc58e3f2ebcc3 Mon Sep 17 00:00:00 2001 From: Paveł Tyślacki Date: Thu, 27 Dec 2018 22:21:59 +0300 Subject: Fixed #30062 -- Added support for unique conditional constraints. --- docs/ref/models/constraints.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'docs/ref') diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt index c92d2dde37..acf3375b4a 100644 --- a/docs/ref/models/constraints.txt +++ b/docs/ref/models/constraints.txt @@ -69,3 +69,17 @@ date. .. attribute:: UniqueConstraint.name The name of the constraint. + +``condition`` +------------- + +.. attribute:: UniqueConstraint.condition + +A :class:`Q` object that specifies the condition you want the constraint to +enforce. + +For example, ``UniqueConstraint(fields=['user'], condition=Q(status='DRAFT')`` +ensures that each user only has one draft. + +These conditions have the same database restrictions as +:attr:`Index.condition`. -- cgit v1.3