Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Meta.indexes in a superclass breaks proxy models #58

Open
craigds opened this issue Jul 26, 2021 · 1 comment
Open

Using Meta.indexes in a superclass breaks proxy models #58

craigds opened this issue Jul 26, 2021 · 1 comment

Comments

@craigds
Copy link
Owner

craigds commented Jul 26, 2021

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.
@adamchainz
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants