Skip to content

Versions: enforce using project.versions instead of Version.filter(project=project) #12411

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Aug 14, 2025

When using Version.filter(project=project), django will re-fetch the project for each version when accessed, but when using project.versions django will share the same project instance on each version, so fewer queries and less memory is used. I checked and all querysets in public make use of self.filter, so everything should work properly.

There are probably more querysets that can benefit from a similar change, but this is just a start.

@stsewd stsewd requested a review from a team as a code owner August 14, 2025 19:43
@stsewd stsewd requested a review from agjohnson August 14, 2025 19:43
@humitos
Copy link
Member

humitos commented Aug 15, 2025

Can we document this somehow? I'm sure we will be tempted to re add the project= argument we are removing now and use the slow version of the query again.

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 this pull request may close these issues.

2 participants