0% found this document useful (0 votes)
14 views16 pages

TS-10 Django Authentication

Uploaded by

Nazmul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views16 pages

TS-10 Django Authentication

Uploaded by

Nazmul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Django

Authentication
Authorization, Authentication,
Login & Registration

Program: EDGE-CSE CUET DIGITAL Instructor:


SKILLS TRAINING Tanveer Rahman,
Sr. Software Engineer,
Course: Python (Django) [Intermediate]
Friends Corp.
Lecture: Training Session-10 Chuo-ku, Tokyo, JP
Date: 12th October, 2024 [email protected],
Duration: (1+1) hours 01626735005
Agenda

User Authentication
Implementing Login
and Authorization
System

Implementing
Practical Tasks
Registration System
User Authentication:
Verifying the identity of a
Introducti user (e.g., username and
User Authorization:
password).
on to Determining what an
Django authenticated user
can do provides
Django (permissions,
built-in
Authentic groups, etc.).
support for user
ation authentication with
customizable views,
models, and forms.
User submits
login form with
credentials.
Django
Authenti authenticates
the user by
cation verifying
User session is
credentials.
Workflow created upon
successful
in Django authentication.
Permissions are
checked for
accessing
different views.
Built-in User Model
Attributes:

User username
password
Model email
• first_name, last_name

Overview Customizing the User Model: Use


Django's built-in AbstractUser or
AbstractBaseUser.
Include
Authentication URLs
Setting in the main urls.py

Up
Authentic
Configure Settings:
ation in
• LOGIN_REDIRECT_URL = '/'
Django • LOGOUT_REDIRECT_URL =
'/'
Create Login
View:
• Use Django's built-in
LoginView.
Implemen Create a Login
ting Login Template
• Simple HTML form for
username and
Update URLs
password.
to
include login.
Task 1: Login System (30
Mins)
• Create a login form using Django's LoginView.
• Update URL configurations to include login and
logout paths.
• Create a simple login template to display the login
form.
Create a
Registration Form:
• Use Django's
Implemen UserCreationForm.
Create a View for
ting Registration:
Registrati • Handle form submission
on and user creation.
Update URL
Configurations:
• Add a path for
registration.
Registra
tion
VIEW
Example
* view.py
Task 2: Registration System
(30 Mins)
• Create a registration view using UserCreationForm.
• Add registration URL to your URL configurations.
• Create a registration template to display the
registration form.
Built-in Permission
System:
Authoriza • is_authenticated:
tion with Checks if the user is
Permissio logged in.
•Assign
is_staff, is_superuser:
ns
Permissions
Special user statuses.
•using
Custom Django
permissions
can be added to
Admin
models. or code.
Task 3: Implementing
Permissions (15 Mins)
• Add a custom permission to a model.
• Use a view decorator to restrict access based on the
permission.
• Test the permission by logging in with different user
roles.
recap

Login and
Registration
Authorizatio
Authenticati Systems:
n: Managing
on: Verifying Implemented
user
user identity. using built-in
permissions.
Django views
and forms.
Django
Additiona Documentation:
https://docs.djangopro
l ject.com/en/stable/top
ics/auth/

Resource Django Authentication


s and Authorization
Guide
Q&A
Session

You might also like