Opened 3 weeks ago
Closed 3 weeks ago
#36603 closed Cleanup/optimization (fixed)
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: | Ready for checkin | |
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 (4)
comment:1 by , 3 weeks ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 3 weeks ago
Has patch: | set |
---|
comment:3 by , 3 weeks ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:4 by , 3 weeks ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
In 41bc48a: