Reputation: 7301
Currently, I have 3 models, A, B and C
C has foreign key to B B has foreign key to A
class C(models.Model):
name = models.CharField(max_length=50, db_index=True, unique=True)
b = models.ForeignKey(B)
class B:
...similar to C
class A
...similar to C except for the FK
However, the SQL generated by manage.py sqlindexes app doesn't create indexes for C.name, B.name, and A.name. Anyone know why this happens?
Upvotes: 1
Views: 1597
Reputation: 99751
That looks to me like it'll be because the fields also have unique = True
, so I wouldn't worry too much about it. If you've got unique = True
, then you'll get a unique index (which may or may not be implemented as a database index), so I guess Django just ignores the db_index = True
bit.
I get very similar behaviour for one of my models that is similarly specified. What output do you get when run manage.py sql app
? Do you see the name
fields being created with UNIQUE
?
Upvotes: 1