Skip to content

Commit

Permalink
[2.2.x] Fixed #30362 -- Noted partial indexes and constraints restric…
Browse files Browse the repository at this point in the history
…tions with abstract base classes.

Thanks Carlton Gibson for the review.

Backport of 5df3301 from master
  • Loading branch information
felixxm committed Apr 25, 2019
1 parent 158cfeb commit f24cf51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/ref/models/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ option.
convention is to use ``from django.db import models`` and refer to the
constraints as ``models.<Foo>Constraint``.

.. admonition:: Constraints in abstract base classes

You must always specify a unique name for the constraint. As such, you
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.

``CheckConstraint``
===================

Expand Down
10 changes: 10 additions & 0 deletions docs/ref/models/indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ The name of the index. If ``name`` isn't provided Django will auto-generate a
name. For compatibility with different databases, index names cannot be longer
than 30 characters and shouldn't start with a number (0-9) or underscore (_).

.. admonition:: Partial indexes in abstract base classes

You must always specify a unique name for an index. As such, you
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.


``db_tablespace``
-----------------

Expand Down

0 comments on commit f24cf51

Please sign in to comment.