Skip to content

Don't fetch the whole object when checking permissions #5461

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
wants to merge 1 commit into from

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Mar 14, 2019

This also checks for is_superuser first

Kind of related to #5460

This also checks for is_superuser first

Kind of related to readthedocs#5460
@stsewd stsewd requested a review from a team March 14, 2019 22:35
@stsewd
Copy link
Member Author

stsewd commented Mar 14, 2019

Ok, so we realized that with this change, we'll always hit the db, so #5460 is enough

@stsewd stsewd closed this Mar 14, 2019
@stsewd stsewd deleted the optimize-permission-check branch March 14, 2019 22:39
@davidfischer
Copy link
Contributor

Prefetching objects in Django with prefetch_related or prefetch_related_objects does an optimization such that project.users.all() won't hit the database. However, project.users.filter(pk=user.pk).exists() (or any filter query) will always hit the database. I think this confusion though means that AdminPermissionBase probably warrants a comment.

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