Skip to content

[django] Multi-table inheritance is broken when querying common list #36

@theoden-dd

Description

@theoden-dd

The use case is querying the common list using a base model when going to access submodel fields.
In this case you have to make .select_related('submodel1_rel_field', 'submodel2_rel_field') to avoid N+1 queries.
But if you have 0 records for any submodel you get exception

Potential unnecessary eager load detected on BaseModel.submodel_rel_field

The current workaround is:

NPLUSONE_WHITELIST = [
    {'model': 'admin.*'},
    {'label': 'unused_eager_load', 'model': 'app.BaseModel', 'field': 'submodel1_rel_field'},
    {'label': 'unused_eager_load', 'model': 'app.BaseModel', 'field': 'submodel2_rel_field'},
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions