Django Model Index was introduced in Django 1.11
What is Model.indexes:
By default, indexes are created in ascending order for each column. To define an index in descending order for a column, add a hyphen in front of the field name.
At your request, models.Index(fields=['last_name', 'first_name','-date_of_birth',]), will create SQL with (last_name, first_name, date_of_birth DESC).
Let's get to your question,
you set the difference between the two queries,
both will take models.Index(fields=['-date_of_birth',]),
because at least one of them will override the assigned variables. from your question the smallest dateofbirth value, so it will be redefined over two lines.
, since the preferred document method, because the index field must be on the same list .. so django will prepare SQL indexing from the list of fields ...
models.Index(fields=['last_name', 'first_name', '-date_of_birth']),
Mohideen ibn mohammed
source share