diff options
| author | Simon Charette <charette.s@gmail.com> | 2018-08-05 22:30:44 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-11-13 17:57:27 -0500 |
| commit | db13bca60a6758d5fe63eeb01c00c3f54f650715 (patch) | |
| tree | e1c3620032623488f2dac8320e3e646ed18cef1a /docs/ref | |
| parent | 8eae094638acf802c8047b341d126d94bc9b45a3 (diff) | |
Fixed #29641 -- Added support for unique constraints in Meta.constraints.
This constraint is similar to Meta.unique_together but also allows
specifying a name.
Co-authored-by: Ian Foote <python@ian.feete.org>
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/constraints.txt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt index 9e24a1cad8..5c94ce094a 100644 --- a/docs/ref/models/constraints.txt +++ b/docs/ref/models/constraints.txt @@ -43,3 +43,28 @@ ensures the age field is never less than 18. .. attribute:: CheckConstraint.name The name of the constraint. + +``UniqueConstraint`` +==================== + +.. class:: UniqueConstraint(*, fields, name) + + Creates a unique constraint in the database. + +``fields`` +---------- + +.. attribute:: UniqueConstraint.fields + +A list of field names that specifies the unique set of columns you want the +constraint to enforce. + +For example ``UniqueConstraint(fields=['room', 'date'], name='unique_location')`` +ensures only one location can exist for each ``date``. + +``name`` +-------- + +.. attribute:: UniqueConstraint.name + +The name of the constraint. |
