mirror of
https://github.com/django/django.git
synced 2025-09-08 03:30:48 +00:00
Fixed #30062 -- Added support for unique conditional constraints.
This commit is contained in:
parent
1e837c4b23
commit
b69f8eb04c
8 changed files with 291 additions and 26 deletions
|
@ -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`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue