Opened 2 hours ago
Last modified 19 minutes ago
#36603 assigned Cleanup/optimization
Make LoginRequiredMiddleware avoid fetching request.user for public views
Reported by: | Adam Johnson | Owned by: | Adam Johnson |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
LoginRequiredMiddleware checks request.user.is_authenticated
before view_func.login_required
. This causes unnecessary database queries for public views, fetching the current session and user, even though the check doesn't need that information. Rearranging the condition checks to first see if the view is public would avoid that extra work.
Change History (2)
comment:1 by , 56 minutes ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 19 minutes ago
Has patch: | set |
---|
Note:
See TracTickets
for help on using tickets.