summaryrefslogtreecommitdiff
path: root/docs/ref/models
diff options
context:
space:
mode:
Diffstat (limited to 'docs/ref/models')
-rw-r--r--docs/ref/models/index.txt1
-rw-r--r--docs/ref/models/indexes.txt48
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.