summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/models/constraints.txt25
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.