summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDavid Sanders <shang.xiao.sanders@gmail.com>2025-08-12 01:32:24 +1000
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-08-13 09:16:06 +0200
commit4926591343756d9fdd5d57680e021364ff71288f (patch)
tree28c8bc4c576cdeb9275b7b4c829f4d001f46009a /docs
parent1d9f6c3270649a4b103df9bfd18733a750341a4e (diff)
[5.2.x] Aligned format of constraint examples in docs/ref/models/constraints.txt.
Backport of fda3c1712a1eb7b20dfc91e6c9abae32bd64d081 from main.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/constraints.txt18
1 files changed, 12 insertions, 6 deletions
diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt
index 5bf5b4d969..3ecf99ee9a 100644
--- a/docs/ref/models/constraints.txt
+++ b/docs/ref/models/constraints.txt
@@ -26,8 +26,9 @@ option.
(including ``name``) each time. To work around name collisions, part of the
name may contain ``'%(app_label)s'`` and ``'%(class)s'``, which are
replaced, respectively, by the lowercased app label and class name of the
- concrete model. For example ``CheckConstraint(condition=Q(age__gte=18),
- name='%(app_label)s_%(class)s_is_adult')``.
+ concrete model. For example::
+
+ CheckConstraint(condition=Q(age__gte=18), name="%(app_label)s_%(class)s_is_adult")
.. admonition:: Validation of Constraints
@@ -103,7 +104,10 @@ This method must be implemented by a subclass.
A :class:`Q` object or boolean :class:`~django.db.models.Expression` that
specifies the conditional check you want the constraint to enforce.
-For example, ``CheckConstraint(condition=Q(age__gte=18), name='age_gte_18')``
+For example::
+
+ CheckConstraint(condition=Q(age__gte=18), name="age_gte_18")
+
ensures the age field is never less than 18.
.. admonition:: Expression order
@@ -164,9 +168,11 @@ Functional unique constraints have the same database restrictions as
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_booking')`` ensures each room can only be booked once for each
-date.
+For example::
+
+ UniqueConstraint(fields=["room", "date"], name="unique_booking")
+
+ensures each room can only be booked once for each date.
``condition``
-------------