mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #30397 -- Added app_label/class interpolation for names of indexes and constraints.
This commit is contained in:
parent
8233144ca0
commit
febe136d4c
9 changed files with 166 additions and 11 deletions
|
@ -25,8 +25,11 @@ option.
|
|||
cannot normally specify a constraint on an abstract base class, since the
|
||||
:attr:`Meta.constraints <django.db.models.Options.constraints>` option is
|
||||
inherited by subclasses, with exactly the same values for the attributes
|
||||
(including ``name``) each time. Instead, specify the ``constraints`` option
|
||||
on subclasses directly, providing a unique name for each constraint.
|
||||
(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(check=Q(age__gte=18),
|
||||
name='%(app_label)s_%(class)s_is_adult')``.
|
||||
|
||||
.. admonition:: Validation of Constraints
|
||||
|
||||
|
@ -63,6 +66,10 @@ ensures the age field is never less than 18.
|
|||
|
||||
The name of the constraint.
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
|
||||
Interpolation of ``'%(app_label)s'`` and ``'%(class)s'`` was added.
|
||||
|
||||
``UniqueConstraint``
|
||||
====================
|
||||
|
||||
|
@ -89,6 +96,10 @@ date.
|
|||
|
||||
The name of the constraint.
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
|
||||
Interpolation of ``'%(app_label)s'`` and ``'%(class)s'`` was added.
|
||||
|
||||
``condition``
|
||||
-------------
|
||||
|
||||
|
|
|
@ -55,9 +55,15 @@ than 30 characters and shouldn't start with a number (0-9) or underscore (_).
|
|||
cannot normally specify a partial index on an abstract base class, since
|
||||
the :attr:`Meta.indexes <django.db.models.Options.indexes>` option is
|
||||
inherited by subclasses, with exactly the same values for the attributes
|
||||
(including ``name``) each time. Instead, specify the ``indexes`` option
|
||||
on subclasses directly, providing a unique name for each index.
|
||||
(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 ``Index(fields=['title'],
|
||||
name='%(app_label)s_%(class)s_title_index')``.
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
|
||||
Interpolation of ``'%(app_label)s'`` and ``'%(class)s'`` was added.
|
||||
|
||||
``db_tablespace``
|
||||
-----------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue