Skip to content

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

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

Closed
Archmonger opened this issue Jan 13, 2023 · 0 comments · Fixed by #123
Closed

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

Archmonger opened this issue Jan 13, 2023 · 0 comments · Fixed by #123

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Jan 13, 2023

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")
@Archmonger Archmonger changed the title use_query doesn't work with modified related_name use_query doesn't work with fields using modified related_name Jan 13, 2023
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

Successfully merging a pull request may close this issue.

1 participant