I am trying to add indexes on model fields using Field.db_index for an app that has migrations. Looking at Django\'s documentation all I need to do is to set
Field.db_index
This problem still exists in django2.1. I solved it by using the indexes Meta option. This is a bit cleaner than the index_together solution.
index_together
class Person(models.Model): first_name = models.CharField() last_name = models.CharField() class Meta: indexes = [ models.Index(fields=['last_name']), ]