diff options
Diffstat (limited to 'docs/ref/models')
| -rw-r--r-- | docs/ref/models/constraints.txt | 14 |
1 files changed, 14 insertions, 0 deletions
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`. |
