Skip to content

Commit fda3c17

Browse files
shangxiaosarahboyce
authored andcommitted
Aligned format of constraint examples in docs/ref/models/constraints.txt.
1 parent a9b07ce commit fda3c17

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

docs/ref/models/constraints.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ option.
2626
(including ``name``) each time. To work around name collisions, part of the
2727
name may contain ``'%(app_label)s'`` and ``'%(class)s'``, which are
2828
replaced, respectively, by the lowercased app label and class name of the
29-
concrete model. For example ``CheckConstraint(condition=Q(age__gte=18),
30-
name='%(app_label)s_%(class)s_is_adult')``.
29+
concrete model. For example::
30+
31+
CheckConstraint(condition=Q(age__gte=18), name="%(app_label)s_%(class)s_is_adult")
3132

3233
.. admonition:: Validation of Constraints
3334

@@ -99,7 +100,10 @@ This method must be implemented by a subclass.
99100
A :class:`Q` object or boolean :class:`~django.db.models.Expression` that
100101
specifies the conditional check you want the constraint to enforce.
101102

102-
For example, ``CheckConstraint(condition=Q(age__gte=18), name='age_gte_18')``
103+
For example::
104+
105+
CheckConstraint(condition=Q(age__gte=18), name="age_gte_18")
106+
103107
ensures the age field is never less than 18.
104108

105109
.. admonition:: Expression order
@@ -156,9 +160,11 @@ Functional unique constraints have the same database restrictions as
156160
A list of field names that specifies the unique set of columns you want the
157161
constraint to enforce.
158162

159-
For example, ``UniqueConstraint(fields=['room', 'date'],
160-
name='unique_booking')`` ensures each room can only be booked once for each
161-
date.
163+
For example::
164+
165+
UniqueConstraint(fields=["room", "date"], name="unique_booking")
166+
167+
ensures each room can only be booked once for each date.
162168

163169
``condition``
164170
-------------

0 commit comments

Comments
 (0)