Opened 7 years ago

Closed 5 years ago

#15033 closed Bug (duplicate)

sqlindexes doesn't create indexes for ForeignKeys on normal ManyToManyFields

Reported by: Craig de Stigter Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


this comment implies that the ForeignKeys created by ManyToManyField tables should also have indexes (makes sense, right? Otherwise we'll have to always create them with custom SQL, or define a through relation every time, gross.)

However sqlindexes doesn't create the indexes. It does create the (from, to) unique constraints, but that's actually not very useful for many queries...

The fix is to change django/core/management/

for model in models.get_models(app):


for model in models.get_models(app, include_auto_created=True):

Tested in 1.2.4 and trunk (r15153).

Change History (6)

comment:1 Changed 7 years ago by Russell Keith-Magee

Triage Stage: UnreviewedReady for checkin

comment:2 Changed 7 years ago by Luke Plant

Component: Core frameworkDatabase layer (models, ORM)
Needs documentation: set
Triage Stage: Ready for checkinAccepted

I think this needs a documentation change, like the note about the new index here:

I'm guessing Russell overlooked that, or clicked 'Ready for checkin' instead of 'Accepted', and I'll adjust as I think necessary - apologies to Russell if I've misunderstood something.

comment:3 Changed 7 years ago by anonymous

Severity: Normal
Type: Bug

comment:4 Changed 6 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 6 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 5 years ago by Tim Graham

Resolution: duplicate
Status: newclosed

Duplicate of #15697 (which has a patch)

Note: See TracTickets for help on using tickets.
Back to Top