← Django learning path
Django · Module 8 of 10

Authentication and permissions

Log users in and control what they can do.

📖 Key ideas

  1. django.contrib.auth provides users, groups and permissions.
  2. Built-in LoginView and LogoutView.
  3. @login_required protects views.
  4. request.user gives the current user.
  5. Passwords are hashed automatically (PBKDF2 by default).
💡 Real-life example: Groups are department badges: give a badge and the person gets all its door permissions.
@login_requiredDecorator requiring login
request.userThe current user
GroupSet of permissions for many users
PBKDF2Default password hashing