Skip to content

use_query doesn't work with fields using modified related_name #122

Description

@Archmonger

Discussed in #121

Originally posted by numpde January 13, 2023
I have a model Compiled with a foreign key to Module, declared as follows:

parent = models.ForeignKey(Module, ..., related_name="compiled")

With use_query, this fails because it attempts to fetch compiled_set, I believe, due to this line in utils:

prefetch_fields.append(f"{field.name}_set")

Maybe it should be

prefetch_fields.append(field.related_name or f"{field.name}_set")

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