V
V
Volton2017-05-08 20:34:58
Django
Volton, 2017-05-08 20:34:58

What is the best way to do indexing in Django 1.11?

I'm making an application on Django 1.11.
Advise whether it is worth creating indexes in the database in a new way:

from django.db import models

class Customer(models.Model):
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)

    class Meta:
        indexes = [
            models.Index(fields=['last_name', 'first_name']),
        ]

or better the old fashioned way, in the model field itself, specifying db_index=True ?
The project will be developed and maintained in the 1.11 branch with a PostgreSQL base.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question