#36603: Make LoginRequiredMiddleware avoid fetching request.user for public views
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: | Status: assigned
Cleanup/optimization |
Component: | Version: dev
contrib.auth |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36603>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.