[Django]-Django Indexes with Model Inheritance

3👍

The name indexes [Django-doc] is plural, it expects a list of Index objects [Django-doc]:

A list of indexes that you want to define on the model

So you should not assign an Index object itself, but a list of Index objects:

class Test(models.Model):
    id = models.BigAutoField(primary_key=True)
    class Meta:
        abstract = True
        indexes = [models.Index(fields=['-id'])]

Leave a comment