mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #34140 -- Reformatted code blocks in docs with blacken-docs.
This commit is contained in:
parent
6015bab80e
commit
14459f80ee
193 changed files with 5797 additions and 4481 deletions
|
@ -126,7 +126,7 @@ ensures the age field is never less than 18.
|
|||
to behave the same as check constraints validation. For example, if ``age``
|
||||
is a nullable field::
|
||||
|
||||
CheckConstraint(check=Q(age__gte=18) | Q(age__isnull=True), name='age_gte_18')
|
||||
CheckConstraint(check=Q(age__gte=18) | Q(age__isnull=True), name="age_gte_18")
|
||||
|
||||
``UniqueConstraint``
|
||||
====================
|
||||
|
@ -145,7 +145,7 @@ constraints on expressions and database functions.
|
|||
|
||||
For example::
|
||||
|
||||
UniqueConstraint(Lower('name').desc(), 'category', name='unique_lower_name_category')
|
||||
UniqueConstraint(Lower("name").desc(), "category", name="unique_lower_name_category")
|
||||
|
||||
creates a unique constraint on the lowercased value of the ``name`` field in
|
||||
descending order and the ``category`` field in the default ascending order.
|
||||
|
@ -175,7 +175,7 @@ enforce.
|
|||
|
||||
For example::
|
||||
|
||||
UniqueConstraint(fields=['user'], condition=Q(status='DRAFT'), name='unique_draft_user')
|
||||
UniqueConstraint(fields=["user"], condition=Q(status="DRAFT"), name="unique_draft_user")
|
||||
|
||||
ensures that each user only has one draft.
|
||||
|
||||
|
@ -193,8 +193,8 @@ are ``Deferrable.DEFERRED`` or ``Deferrable.IMMEDIATE``. For example::
|
|||
from django.db.models import Deferrable, UniqueConstraint
|
||||
|
||||
UniqueConstraint(
|
||||
name='unique_order',
|
||||
fields=['order'],
|
||||
name="unique_order",
|
||||
fields=["order"],
|
||||
deferrable=Deferrable.DEFERRED,
|
||||
)
|
||||
|
||||
|
@ -224,7 +224,7 @@ and filter only by unique fields (:attr:`~UniqueConstraint.fields`).
|
|||
|
||||
For example::
|
||||
|
||||
UniqueConstraint(name='unique_booking', fields=['room', 'date'], include=['full_name'])
|
||||
UniqueConstraint(name="unique_booking", fields=["room", "date"], include=["full_name"])
|
||||
|
||||
will allow filtering on ``room`` and ``date``, also selecting ``full_name``,
|
||||
while fetching data only from the index.
|
||||
|
@ -246,7 +246,9 @@ for each field in the index.
|
|||
|
||||
For example::
|
||||
|
||||
UniqueConstraint(name='unique_username', fields=['username'], opclasses=['varchar_pattern_ops'])
|
||||
UniqueConstraint(
|
||||
name="unique_username", fields=["username"], opclasses=["varchar_pattern_ops"]
|
||||
)
|
||||
|
||||
creates a unique index on ``username`` using ``varchar_pattern_ops``.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue