|
79 | 79 |
|
80 | 80 | To define your index, pass the following arguments to the ``models.Index()`` method:
|
81 | 81 |
|
82 |
| -- ``expressions``: Specifies a database expression to index. If you don't pass |
83 |
| - the ``fields`` argument, this argument is required. To learn more about this |
84 |
| - argument, see the :ref:`django-indexes-expressions` section of this guide. |
85 |
| - |
86 |
| -- ``fields``: Specifies a list of fields to index. If you don't pass the |
87 |
| - ``expressions`` argument, this argument is required. |
| 82 | +- ``fields``: Specifies a list of fields to index. This argument is required. |
88 | 83 |
|
89 | 84 | - ``name``: Specifies the index name. This argument is optional, and Django
|
90 | 85 | automatically creates an index name if you don't provide one.
|
@@ -204,7 +199,6 @@ index types:
|
204 | 199 |
|
205 | 200 | - :ref:`django-indexes-partial`
|
206 | 201 | - :ref:`django-indexes-unique`
|
207 |
| -- :ref:`django-indexes-expressions` |
208 | 202 |
|
209 | 203 | .. _django-indexes-partial:
|
210 | 204 |
|
@@ -285,33 +279,6 @@ creates a unique compound index on these fields:
|
285 | 279 | class's ``constraint`` option, see `Constraints <{+django-docs+}/ref/models/constraints/>`__
|
286 | 280 | in the Django documentation.
|
287 | 281 |
|
288 |
| -.. _django-indexes-expressions: |
289 |
| - |
290 |
| -Expression Indexes |
291 |
| -~~~~~~~~~~~~~~~~~~ |
292 |
| - |
293 |
| -To create indexes on expressions and database functions, pass the |
294 |
| -``expressions`` argument to the ``models.Index()`` method. When using |
295 |
| -the ``expressions`` argument, you must also pass the ``name`` |
296 |
| -argument to ``models.Index()``. |
297 |
| - |
298 |
| -The following example updates the ``Recipe`` model's ``Meta`` class to create |
299 |
| -an index on the sum of the ``cook_time`` and ``prep_time`` values: |
300 |
| - |
301 |
| -.. literalinclude:: /includes/model-data/indexes.py |
302 |
| - :start-after: start-expression |
303 |
| - :end-before: end-expression |
304 |
| - :language: python |
305 |
| - :copyable: |
306 |
| - :emphasize-lines: 3-7 |
307 |
| - |
308 |
| -.. tip:: |
309 |
| - |
310 |
| - The preceding example uses ``F`` objects to create a database |
311 |
| - function. To learn more about ``F`` objects, see `F() expressions |
312 |
| - <{+django-docs+}/ref/models/expressions/#f-expressions>`__ in the Django |
313 |
| - documentation. |
314 |
| - |
315 | 282 | Additional Information
|
316 | 283 | ----------------------
|
317 | 284 |
|
|
0 commit comments