login_required and Protecting Views
Restrict pages to authenticated users.
Some Pages Are Private
A dashboard or profile page should only open for signed-in users. Django makes protecting those views simple and consistent. 🚧
Meet login_required
The login_required decorator guards a view: anonymous visitors are bounced to the login page automatically.
from django.contrib.auth.decorators import login_requiredAll lessons in this course
- The User Model and authenticate()
- login, logout, and Auth Views
- Registration with UserCreationForm
- login_required and Protecting Views