django-typed-models icon indicating copy to clipboard operation
django-typed-models copied to clipboard

Using `Meta.indexes` in a superclass breaks proxy models

Open craigds opened this issue 4 years ago • 1 comments

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.

craigds avatar Jul 26 '21 05:07 craigds

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.

adamchainz avatar Oct 24 '23 09:10 adamchainz