Skip to content

Optimize M2M Field #9276

@jonasN5

Description

@jonasN5

This is linked to #4917

return relationship.all() if hasattr(relationship, 'all') else relationship

Why can't we just allow some customization at this line? Usually with any toolbox, we provide a best effort default and give the user the option to customize. In this case, the relations will ALWAYS be fetched with .all(). I have a simple case where I need an annotation on each child and so a single query is enough, if done on the ManyRelatedField level. How about making the ManyRelatedField also accept a queryset argument and default to .all() if there is no queryset argument?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions