summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorcan <cansarigol@derinbilgi.com.tr>2019-07-05 15:15:41 +0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-07-08 14:57:56 +0200
commitfebe136d4c3310ec8901abecca3ea5ba2be3952c (patch)
tree4eeae36c3ae832a90f8a4721b2de54ea555a8478 /docs
parent8233144ca0c93b589b61a2ad0fb7c851f3356a3b (diff)
Fixed #30397 -- Added app_label/class interpolation for names of indexes and constraints.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/constraints.txt15
-rw-r--r--docs/ref/models/indexes.txt10
-rw-r--r--docs/releases/3.0.txt5
3 files changed, 26 insertions, 4 deletions
diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt
index d172353326..b5b77b8654 100644
--- a/docs/ref/models/constraints.txt
+++ b/docs/ref/models/constraints.txt
@@ -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``
-------------
diff --git a/docs/ref/models/indexes.txt b/docs/ref/models/indexes.txt
index 13e37f78c7..5909ee9c64 100644
--- a/docs/ref/models/indexes.txt
+++ b/docs/ref/models/indexes.txt
@@ -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``
-----------------
diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt
index 6c25f79d7b..c4cc480031 100644
--- a/docs/releases/3.0.txt
+++ b/docs/releases/3.0.txt
@@ -263,6 +263,11 @@ Models
* Allowed symmetrical intermediate table for self-referential
:class:`~django.db.models.ManyToManyField`.
+* The ``name`` attributes of :class:`~django.db.models.CheckConstraint`,
+ :class:`~django.db.models.UniqueConstraint`, and
+ :class:`~django.db.models.Index` now support app label and class
+ interpolation using the ``'%(app_label)s'`` and ``'%(class)s'`` placeholders.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~