django-typed-models
django-typed-models copied to clipboard
Using `Meta.indexes` in a superclass breaks proxy models
django-admin makemigrations gives these errors when you add a Meta.indexes = [...] on a base model:
myapp.SpecificThing: (models.E016) 'indexes' refers to field 'permissions' which is not local to model 'SpecificThing'.
HINT: This issue may be caused by multi-table inheritance.
myapp.OtherThing: (models.E016) 'indexes' refers to field 'permissions' which is not local to model 'OtherThing'.
HINT: This issue may be caused by multi-table inheritance.
I encountered this yesterday. It seems that TypedModel changes all fields to appear in the _meta.local_fields of the parent class, and none in the child class. Thus an index on a child class fails this check because it thinks the field lives on its parent table, when it doesn't.