DjangoMiddlewareGuard
A project middleware in settings.MIDDLEWARE that turns an
unauthenticated request away (a login redirect, a 401/403) unless its
path is exempt. It is judged by its definition: its __call__ (or
process_request) is walked for an anonymous caller at the endpoint's
path and verb, and it guards the endpoint when every way through that
serves the view needs a logged-in caller.
Conditions evaluate to T / F, Choice (the caller decides: a query
parameter, or a path test the endpoint's <path:...> placeholder may or
may not satisfy) or Unknown (a setting, a test this cannot read). A
view served only behind an Unknown keeps the guard, with a note.
Constants
What only a logged-in caller passes: AnonymousUser is never staff,
active or permitted.
A credential the caller sends in a header or cookie, which an anonymous caller does not have.
HttpResponseRedirect(settings.LOGIN_URL), redirect(reverse("account_login")).
The request path itself. A [:N] slice only truncates it; any other
transform (lstrip, [1:], split, lower) is not the path.