{% extends "base.html" %} {% block title %}Public Page – django-login-default{% endblock %} {% block content %}
The view uses NoLoginRequiredMixin, which sets
no_login_required = True on the class. The middleware sees that
and lets the request through.
Class-based view:
from django_login_default.mixins import NoLoginRequiredMixin
class PublicView(NoLoginRequiredMixin, TemplateView):
template_name = "public.html"
Function-based view:
from django_login_default.decorators import no_login_required
@no_login_required
def public_page(request):
return render(request, "public.html")
Both approaches do the same thing — they set an attribute that the middleware checks before deciding whether to redirect.