diff options
| author | Akshesh <aksheshdoshi@gmail.com> | 2016-06-25 22:02:56 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-06-27 10:41:01 -0400 |
| commit | 156e2d59cf92eb252c2f6ef9bb0b65f26c707de2 (patch) | |
| tree | a385db97c67f6b8504954c3df3ac88f169d13f8c /docs/ref/models | |
| parent | c962b9104a22505a7d6c57bbec9eda163f486c7d (diff) | |
Fixed #26709 -- Added class-based indexes.
Added the AddIndex and RemoveIndex operations to use them in migrations.
Thanks markush, mjtamlyn, timgraham, and charettes for review and advice.
Diffstat (limited to 'docs/ref/models')
| -rw-r--r-- | docs/ref/models/index.txt | 1 | ||||
| -rw-r--r-- | docs/ref/models/indexes.txt | 48 |
2 files changed, 49 insertions, 0 deletions
diff --git a/docs/ref/models/index.txt b/docs/ref/models/index.txt index 103775e269..d731ee37dc 100644 --- a/docs/ref/models/index.txt +++ b/docs/ref/models/index.txt @@ -8,6 +8,7 @@ Model API reference. For introductory material, see :doc:`/topics/db/models`. :maxdepth: 1 fields + indexes meta relations class diff --git a/docs/ref/models/indexes.txt b/docs/ref/models/indexes.txt new file mode 100644 index 0000000000..c3c8d1b6eb --- /dev/null +++ b/docs/ref/models/indexes.txt @@ -0,0 +1,48 @@ +===================== +Model index reference +===================== + +.. module:: django.db.models.indexes + +.. currentmodule:: django.db.models + +.. versionadded:: 1.11 + +Index classes ease creating database indexes. This document explains the API +references of :class:`Index` which includes the `index options`_. + +.. admonition:: Referencing built-in indexes + + Indexes are defined in ``django.db.models.indexes``, but for convenience + they're imported into :mod:`django.db.models`. The standard convention is + to use ``from django.db import models`` and refer to the indexes as + ``models.<IndexClass>``. + +``Index`` options +================= + +.. class:: Index(fields=[], name=None) + + Creates an index (B-Tree) in the database. + +``fields`` +----------- + +.. attribute:: Index.fields + +A list of the name of the fields on which the index is desired. + +``name`` +-------- + +.. attribute:: Index.name + +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 (_). + +.. seealso:: + + Use the :class:`~django.db.migrations.operations.AddIndex` and + :class:`~django.db.migrations.operations.RemoveIndex` operations to add + and remove indexes. |
