0Pricing
Django Academy · Lesson

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_required

All lessons in this course

  1. The User Model and authenticate()
  2. login, logout, and Auth Views
  3. Registration with UserCreationForm
  4. login_required and Protecting Views
← Back to Django Academy