0% found this document useful (0 votes)
34 views

Unit-3 - Integrating Accounts & Authentication On Django

The document provides information about a course on Python web development with the Django framework taught by Priya Singh. It includes details about the course units and syllabus, evaluation scheme, course objectives and outcomes, as well as program outcomes and their mapping to course outcomes.

Uploaded by

sumitrawal2020
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)
34 views

Unit-3 - Integrating Accounts & Authentication On Django

The document provides information about a course on Python web development with the Django framework taught by Priya Singh. It includes details about the course units and syllabus, evaluation scheme, course objectives and outcomes, as well as program outcomes and their mapping to course outcomes.

Uploaded by

sumitrawal2020
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/ 79

Noida Institute of Engineering and Technology, Greater Noida

Python Web Development with


Django

Unit: III

Integrating Accounts & Authentication on Django

Priya Singh
Course Details
(Asst. Professor)
(B. Tech. 5th Sem)
CSE Department

05/19/2024 Priya Singh Python web development with Django Unit III 1
Faculty Introduction

Name Priya Singh


Qualification M. Tech. (Computer Engineering)
Designation Assistant Professor
Department Computer Science & Engineering
Total Experience 3 years
NIET Experience 1 years
Subject Taught Design & Analysis of Algorithm, Data Structures, Artificial
Intelligence, Soft Computing, C Programming, Web Technology,
Discrete Mathematics.

05/19/2024 Priya Singh Python web development with Django Unit III 2
Evaluation Scheme

Python Web development with Django (Elective I)


Design Pattern (Elective II)

Priya Singh Python web development with Django


05/19/2024 Unit III 3
Syllabus

UNIT-I: Python libraries for web development

Collections-Container datatypes, Tkinter-GUI applications, Requests-


HTTP requests, BeautifulSoup4-web scraping, Scrapy, Zappa, Dash,
CherryPy, TurboGears, Flask, Web2Py,
Bottle, Falcon, CubicWeb, Quixote, Pyramid.

05/19/2024 4
Priya Singh Python web development with Django Unit III
Syllabus

UNIT-II: Introduction to Django Framework

Understanding Django environment, Features of Django and Django


architecture, MVC &MTV, Urls and Views, Mapping the views to URLs,
Django Template, Template inheritance Django Models, Creating model for
site, Converting the model into a table, Fields in Models, Integrating
Bootstrap into Django, Creating tables, Creating grids, Creating carousels.

05/19/2024 Priya Singh Python web development with Django Unit III 5
Syllabus

UNIT-III: Integrating Accounts & Authentication on Django

Introduction to Django Authentication System, Security Problem & Solution


with Django Creating Registration Form using Django, Adding Email Field In
Forms, Configuring email settings, Sending emails with Django, Adding Grid
Layout On Registration Page, Adding Page Restrictions, Login Functionality Test
and Logout.

05/19/2024 Priya Singh Python web development with Django Unit III 6
Syllabus

UNIT-IV: Connecting SQLite with Django

Database Migrations, Fetch Data From Database, Displaying Data On


Templates, Adding Condition On Data, Sending data from url to view,
Sending data from view to template, Saving objects into database,
Sorting objects, Filtering objects, Deleting objects, Difference between
session and cookie, Creating sessions and cookies in Django.

05/19/2024 Priya Singh Python web development with Django Unit III 7
Syllabus

UNIT-V: Deploying Django Web Application on Cloud

Creating a functional website in Django, Four Important Pillars to


Deploy, Registering on Heroku and GitHub, Push project from Local
System to GitHub, Working with Django Heroku
Working with Static Root, Handling WSGI with gunicorn, Setting up
Database & adding users

05/19/2024 Priya Singh Python web development with Django Unit III 8
Branch Wise Application

1. Real time web analytics


2. Digital Advertising
3. E-Commerce
4. Publishing
5. Massively Multiplayer Online Games
6. Backend Services and Messaging
7. Project Management & Collaboration
8. Real time Monitoring Services
9.Live Charting and Graphing
10. Group and Private Chat

05/19/2024 Priya Singh Python web development with Django Unit III 9
Course Objective

In this semester, the students will

Study how to shows relationships and interactions between frontend &backend

Study to speed up the development process by providing well-tested, proven


development/design paradigms.

Select a specific framework for the development of a given website or webapp.

Analyzing and creating a functional website in Django and deploy Django Web
Application on Cloud.

05/19/2024 Priya Singh Python web development with Django Unit III 10
Course Outcomes (COs)

At the end of course, the student will be able to:


CO1 : Apply the knowledge of python programing that are vital in understanding Django application

CO2 : Demonstrate web application framework (Django) to design and implement dynamic website

CO3 : Implementing and analyzing the concept of Integrating Accounts & Authentication on Django

CO4 : Understand the impact of web designing by database connectivity with SQLite

CO5 : Analyzing & Creating a functional website in Django and deploy Django Web Application Cloud

05/19/2024 Priya Singh Python web development with Django Unit III 11
Program Outcomes (POs)

Engineering Graduates will be able to:

PO1 : Engineering Knowledge

PO2 : Problem Analysis

PO3 : Design/Development of solutions

PO4 : Conduct Investigations of complex problems

PO5 : Modern tool usage

PO6 : The engineer and society


05/19/2024 Priya Singh Python web development with Django Unit III 12
Program Outcomes (POs)

Engineering Graduates will be able to:

PO7 : Environment and sustainability

PO8 : Ethics

PO9 : Individual and teamwork

PO10 : Communication

PO11 : Project management and finance

PO12 : Life-long learning


05/19/2024 Priya Singh Python web development with Django Unit III 13
COs - POs Mapping

CO.K PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12

CO1 2 2 2 3 3 - - - - - - -

CO2 3 2 3 2 3 - - - - - - -

CO3 3 2 3 2 3 - - - - - - -

CO4 3 2 3 2 3 - - - - - - -

CO5 3 2 3 3 3 - - - - - - -

AVG 2.8 2.0 2.8 2.4 3.0 - - - - - - -

05/19/2024 Priya Singh Python web development with Django Unit III 14
Program Specific Outcomes(PSOs)
Program Specific
S. No. PSO Description
Outcomes (PSO)

1 PSO1 Understand to shows relationships and interactions


between classes or objects of a pattern.

2 PSO2 Study to speed up the development process by


providing well-tested, proven development

3 PSO3 Select a specific design pattern for the solution of a


given design problem

Create a catalogue entry for a simple design pattern


4 PSO4 whose purpose and application is understood.

05/19/2024 Priya Singh Python web development with Django Unit III 15
COs - PSOs Mapping

CO.K PSO1 PSO2 PSO3 PSO4

CO1 3 - - -

CO2 3 3 - -

CO3 3 3 - -

CO4 3 3 - -

CO5 3 3 - -

05/19/2024 Priya Singh Python web development with Django Unit III 16
Program Educational Objectives (PEOs)

Program Educational
PEOs Description
Objectives (PEOs)
To have an excellent scientific and engineering breadth so as to comprehend,
PEOs analyze, design and provide sustainable solutions for real-life problems using state-
of-the-art technologies.

To have a successful career in industries, to pursue higher studies or to support


PEOs entrepreneurial endeavors and to face the global challenges.

To have an effective communication skills, professional attitude, ethical values and a


PEOs desire to learn specific knowledge in emerging trends, technologies for research,
innovation and product development and contribution to society.

To have life-long learning for up-skilling and re-skilling for successful professional
PEOs career as engineer, scientist, entrepreneur and bureaucrat for betterment of society.

05/19/2024 Priya Singh Python web development with Django Unit III 17
Result Analysis(Department Result & Subject Result & Individual result

Name of the faculty Subject code Result % of clear passed

05/19/2024 Priya Singh Python web development with Django Unit III 18
Pattern of Online External Exam Question Paper (100 marks)

05/19/2024 Priya Singh Python web development with Django Unit III 19
Pattern of Online External Exam Question Paper (100 marks)

05/19/2024 Priya Singh Python web development with Django Unit III 20
Pattern of Online External Exam Question Paper (100 marks)

05/19/2024 Priya Singh Python web development with Django Unit III 21
Pattern of Online External Exam Question Paper (100 marks)

05/19/2024 Priya Singh Python web development with Django Unit III 22
Pattern of Online External Exam Question Paper (100 marks)

05/19/2024 Priya Singh Python web development with Django Unit III 23
Prerequisite / Recap

• Student should have knowledge of HTML , CSS and JavaScript .

• Students should have good knowledge of Python Programming and

Python coding experience.

• knowledge of Computer and basic skill.

• Good problem solving Skill .

05/19/2024 Priya Singh Python web development with Django Unit III 24
Brief Introduction about the Subject with videos

YouTube /other Video Links


• https://youtu.be/eoPsX7MKfe8?list=PLIdgECt554OVFKXRpo_kuI0XpUQKk0ycO

• https://youtu.be/tA42nHmmEKw?list=PLh2mXjKcTPSACrQxPM2_1Ojus5HX88ht7

• https://youtu.be/8ndsDXohLMQ?list=PLDsnL5pk7-N_9oy2RN4A65Z-PEnvtc7rf

• https://youtu.be/QXeEoD0pB3E?list=PLsyeobzWxl7poL9JTVyndKe62ieoN-MZ3

• https://youtu.be/9MmC_uGjBsM?list=PL3pGy4HtqwD02GVgM96-V0sq4_DSinqvf

05/19/2024 Priya Singh Python web development with Django Unit III 25
Unit III Content

• Introduction to Django Authentication System.


• Security Problem & Solution with Django
• Creating Registration Form using Django.
• Adding Email Field In Forms, Configuring email settings,
Sending emails with Django.
• Adding Grid Layout On Registration Page.
• Adding Page Restrictions, Login Functionality Test and Logout.

05/19/2024 Priya Singh Python web development with Django Unit III 26
Unit III Objective

In Unit III, the students will be able to find


• Introduction to Django Authentication System.
• The idea of a python Library .
• Adding Email Field In Forms, Configuring email settings, Sending
emails with Django
• Adding Page Restrictions, Login Functionality Test and Logout.

05/19/2024 Priya Singh Python web development with Django Unit III 27
Topic Objective

Topic : Introduction to Django Authentication System.

• In this topic, the students will gain to giving users the ability to
create an account they can sign into is a common function for many
websites.

05/19/2024 Priya Singh Python web development with Django Unit III 28
Django authentication system
• The Django authentication system handles both authentication and
authorization. Briefly, authentication verifies a user is who they claim to be, and
authorization determines what an authenticated user is allowed to do.
The auth system consists of:
• Users
• Permissions: Binary (yes/no) flags designating whether a user may perform a
certain task.
• Groups: A generic way of applying labels and permissions to more than one
user.
• A configurable password hashing system
• Forms and view tools for logging in users, or restricting content
• A pluggable backend system
05/19/2024 Priya Singh Python web development with Djan 29
go Unit III
Introduction to Django Authentication System
 For most websites, the basic entity of authentication is a user. A user is
identified by some unique string, which is almost always an email address
or username.

 To prove someone is who they say they are, they must provide a password
when creating an account, and again at any time they want to authenticate
themselves. This should be familiar: you go through this kind of workflow
any time you sign up for a service like Twitter or Netflix.

 Django provides a User model for creating and managing users. Django
users have a username and password, but can also optionally have an
email address and a first and last name:
05/19/2024 Priya Singh Python web development with Django Unit III 30
Introduction to Django Authentication System

05/19/2024 Priya Singh Python web development with Django Unit III 31
Authentication support is bundled as a Django contrib module in django.contrib.auth. By default,
the required configuration is already included in the settings.py generated by django-admin
startproject, these consist of two items listed in your INSTALLED_APPS setting:
1.'django.contrib.auth' contains the core of the authentication framework, and its default
models.
2.'django.contrib.contenttypes' is the Django content type system, which allows
permissions to be associated with models you create.

and these items in your MIDDLEWARE setting:


3.SessionMiddleware manages sessions across requests.
2.AuthenticationMiddleware associates users with requests using sessions.
With these settings in place, running the command manage.py migrate creates the necessary
database tables for auth related models and permissions for any models defined in your installed apps.

05/19/2024 Priya Singh Python web development with Djan 32


go Unit III
Introduction to Django Authentication System

 Django provides a level of security when it comes to passwords. It has a


built-in set of password validators, some of which are enabled by default in
new projects. You can write your own validators to enforce any password
rules you might need, but choose wisely.

 In addition to password validation, Django safely stores password


information by default. Django salts and hashes passwords before storing
them when a user is created, so their plaintext password is no longer
available outside the context of the initial registration request or when
they log in.

05/19/2024 Priya Singh Python web development with Django Unit III 33
Introduction to Django Authentication System
 Django can authenticate a user by checking a supplied set of credentials
against the existing set of registered users. If a user matches, Django
will return that user object. Otherwise, it will return None.

 From django.contrib.auth import authenticate


user = authenticate(
username='rafaela',
password='$uper$ecretpassword'
)
 Django has a vast feature set for authenticating users and interacting
with user objects to get things done.
05/19/2024 Priya Singh Python web development with Django Unit III 34
Security Problem & Solution with Django
 Django is widely lauded for its ease-of-use and pragmatic design, but like
all software it is susceptible to its own share of critical vulnerabilities.
Django's open source popularity means that default attack vectors are
also widely known.

 The application layer is increasingly targeted by hackers for penetration,


and running full stack Python is no more/less vulnerable than any of the
other application stacks. In fact, BitBucket , dpaste, and Mozilla Support
are all employing Python/Django for their mission-critical web offerings,
so have no fear—effective vulnerability management and visibility into
existing Django security gaps can go a long way towards hardening your
Django-based web app against attacks.
05/19/2024 Priya Singh Python web development with Django Unit III 35
Security Problem & Solution with Django

Django’s Top 10 Vulnerabilities

10. Session Modification (CVE-2011-4136)‍

 Versions 1.2.7 and 1.3.x before 1.3.1

 When session details are stored in the cache, root namespacing is used
for both session identifiers and application-data keys. This can allow
remote attackers to modify a session by triggering use of a key that is
equal to that session's identifier.

05/19/2024 Priya Singh Python web development with Django Unit III 36
Security Problem & Solution with Django
Django’s Top 10 Vulnerabilities

9. Session Hijacking (CVE-2014-0482)

 ‍Versions 1.4.14, 1.5.x before 1.5.9, 1.6.x before 1.6.6, and 1.7 .

 Session hijacking involves an attacker gaining unauthorized access to a


system using another user’s session data.

 In this case, when using contrib.auth.backends.RemoteUserBackend,


remote authenticated users can hijack web sessions via vectors related to
the REMOTE_USER header.
05/19/2024 Priya Singh Python web development with Django Unit III 37
Security Problem & Solution with Django
Django’s Top 10 Vulnerabilities

8. Cache Poisoning (CVE-2014-1418)‍

 Versions 1.4 before 1.4.13, 1.5 before 1.5.8, 1.6 before 1.6.5

 Cache poisoning occurs when incorrect data is inserted into a DNS resolver
‘s cache, causing the nameserver to provide an incorrect IP address or
destination. These versions of Django do not not properly include the:
1. Vary: Cookie
2. Cache-Control header in response
 This can allow remote attackers to obtain sensitive information or poison
the cache via a request from certain
Priya Singh
browsers.
Python web development with Django Unit III
05/19/2024 38
Security Problem & Solution with Django

Django’s Top 10 Vulnerabilities

7. Arbitrary URLs Generation (CVE-2012-4520)

 ‍Versions 1.3.x before 1.3.4 and 1.4.x before 1.4.2

 In these versions, the django.http.HttpRequest.get_host function allows


remote attackers to generate and display arbitrary URLs via crafted
username and password Host header values.

05/19/2024 Priya Singh Python web development with Django Unit III 39
Security Problem & Solution with Django
Django’s Top 10 Vulnerabilities

6. CSRF: Unauthenticated Forged Requests (CVE-2011-4140)

V‍ ersions through 1.2.7 and 1.3.x through 1.3.1


 CSRF is short for Cross Site Request Forgery, an attack that utilizes the
user’s web browser to perform an unwanted action on another website in
which the user is currently signed in. The CSRF protection mechanism in
these versions of Django do not properly handle web-server configurations
supporting arbitrary HTTP Host headers, allowing remote attackers to
trigger unauthenticated forged requests via vectors involving a DNS
CNAME record and a web page containing JavaScript code.
05/19/2024 Priya Singh Python web development with Django Unit III 40
Security Problem & Solution with Django

Django’s Top 10 Vulnerabilities

5. CSRF Via Forged AJAX Requests (CVE-2011-0696)

 ‍Versions 1.1.x before 1.1.4 and 1.2.x before 1.2.5

 These versions of Django do not properly validate HTTP requests that


contain an X-Requested-With header, making it trivial for remote attackers
to carry out cross-site request forgery (CSRF) attacks via forged AJAX
requests that leverage a "combination of browser plugins and redirects," a
related issue to CVE-2011-0447.

05/19/2024 Priya Singh Python web development with Django Unit III 41
Security Problem & Solution with Django
Django’s Top 10 Vulnerabilities

4. Directory Traversal (CVE-2011-0698)


 ‍Versions 1.1.x before 1.1.4 and 1.2.x before 1.2.5 on Windows

 In these versions of Django, remote attackers are able to read or execute files via a /
(slash) character in a key in a session cookie, related to session replays.
3. DoS: Via Unspecified Vectors (CVE-2015-5145)
 ‍Versions 1.8.x before 1.8.3

 DoS is short for Denial of Service, and occurs when an attacker brings down a
network/website by flooding it with data packets. The validators.URLValidator in these
versions of Django allow remote attackers to cause a denial of service (CPU
consumption) via unspecified vectors.
05/19/2024 Priya Singh Python web development with Django Unit III 42
Security Problem & Solution with Django

Django’s Top 10 Vulnerabilities

2. DoS : Via Multiple Requests With Unique Session Keys (CVE-2015-5143)

V
‍ ersions before 1.4.21, 1.5.x through 1.6.x, 1.7.x before 1.7.9, and 1.8.x
before 1.8.3

 The session backends in Django allows remote attackers to cause a denial


of service (session store consumption) via multiple requests with unique
session keys.

05/19/2024 Priya Singh Python web development with Django Unit III 43
Security Problem & Solution with Django
Django’s Top 10 Vulnerabilities

1. Type Conversion Vulnerability (CVE-2014-0474)


 ‍Versions before 1.4.11, 1.5.x before 1.5.6, 1.6.x before 1.6.3, and 1.7.x
before 1.7 beta

 In these versions of Django, the following field classes do not properly


perform type conversion :
1. FilePathField
2. GenericIPAddressField
3. IPAddressField
 This gives remote attackers access to unspecified impact and vectors
related to MySQL.
05/19/2024 Priya Singh Python web development with Django Unit III 44
Security Problem & Solution with Django

Remediation of Django
 To fix the above vulnerabilities, you'll need to update the current working
version of your Django framework in all your environments. And while
Django is backwards compatible, it is nonetheless crucial that you identify
any components in your web app that might be impacted by
patching/updating.

 UpGuard provides a way for you to do this easily and automatically with a
few mouse clicks. Our powerful policy engine can validate secure
configurations for all environments, infrastructures, and application stacks. In
this case, a simple Django security policy can be run to check for any of the
above vulnerabilities—as well as new vulnerabilities not yet added to policy.
Our OVAL-backed vulnerability detection and monitoring suite ensures that
all your Django components are free for vulnerabilities and security gaps.
05/19/2024 Priya Singh Python web development with Django Unit III 45
Creating Registration Form using Django
User registration

“ As you may have seen, Django comes with a built-in user registration form. We
just need to configure it to our needs (i.e. collect an email address upon
registration).”
Create the register form

“Django comes with a pre-built register form called UserCreationForm that


connects to the pre-built model User. However, the UserCreationForm only
requires a username and password (password1 is the initial password and
password2 is the password confirmation).To customize the pre-built form, first
create a new file called forms.py in the app directory”.
05/19/2024 Priya Singh Python web development with Django Unit III 46
Creating Registration Form using Django

05/19/2024 Priya Singh Python web development with Django Unit III 47
Creating Registration Form using Django
This new file is created in the same directory as models.py and views.py.
Then call UserCreationForm within a new class called NewUserForm and add
another field called email. Save the email to the user.Add more fields as needed
to the UserCreationForm.

05/19/2024 Priya Singh Python web development with Django Unit III 48
Creating Registration Form using Django
Add a register URL to the app

05/19/2024 Priya Singh Python web development with Django Unit III 49
Creating Registration Form using Django

05/19/2024 Priya Singh Python web development with Django Unit III 50
Creating Registration Form using Django
Add a register function to the views

05/19/2024 Priya Singh Python web development with Django Unit III 51
Creating Registration Form using Django

05/19/2024 Priya Singh Python web development with Django Unit III 52
Adding Email ,Configuring email & Sending emails with Django

Django Mail Setup

 Sending email using Django is pretty easy and require less configuration. In
this lecture, we will send email to provided email.
 For this purpose, we will use Google's SMTP and a Gmail account to set
sender.
 Django provides built-in mail library django.core.mail to send email.
 Before sending email, we need to make some changes in Gmail account
because for security reasons Google does not allow direct access (login) by
any application. So, login to the Gmail account and follow the urls. It will
redirect to the Gmail account settings where we need to allow less secure
apps but toggle the button. See the below screenshot.
05/19/2024 Priya Singh Python web development with Django Unit III 53
Adding Email ,Configuring email & Sending emails with Django

05/19/2024 Priya Singh Python web development with Django Unit III 54
Adding Email ,Configuring email & Sending emails with Django

05/19/2024 Priya Singh Python web development with Django Unit III 55
Adding Email ,Configuring email & Sending emails with Django

05/19/2024 Priya Singh Python web development with Django Unit III 56
Adding Email ,Configuring email & Sending emails with Django

05/19/2024 Priya Singh Python web development with Django Unit III 57
Adding Email ,Configuring email & Sending emails with Django

05/19/2024 Priya Singh Python web development with Django Unit III 58
Adding Grid Layout On Registration Page

05/19/2024 Priya Singh Python web development with Django Unit III 59
Adding Grid Layout On Registration Page
Bootstrap Container
 A Container is the outermost component the Bootstrap framework knows of. Here
the designer can specify the breakpoints of a web page. By default, Bootstrap
offers 4 breakpoints: “large”, “medium”, “small” and “tiny”. These determine for
which kind of screen widths, the grid system may switch the layout.

 The editor window for a Container element offers the possibility to deactivate
certain breakpoints. While this might make sense under certain conditions, it is
safe to always keep all four breakpoints active, since this gives the designer of the
web page the maximum flexibility.

05/19/2024 Priya Singh Python web development with Django Unit III 60
Adding Grid Layout On Registration Page
Small devices exclusively :-

05/19/2024 Priya Singh Python web development with Django Unit III 61
Adding Page Restrictions
 Creating a website is fun, but a login restrictor in your website will make it look more
secure. Django REST Framework is a robust and flexible toolkit for building Web APIs.
The Django login required decorator provide the feature to restrict the access
 We have often visited websites in which we need to log in first before accessing or
visiting other pages. In other words, restricting access.

05/19/2024 Priya Singh Python web development with Django Unit III 62
Adding Page Restrictions

 We also came across some of our projects where we need to do the same
but wonder how? So yes you came to the right place, but before moving
ahead let’s first sneak peek about the login decorator in Django Rest
Framework. login_required() decorator does the following things:-
 Execute normally the view if the user is logged in.
 Redirect the user to the login_url path if the user is not logged in.
 Syntax:-

 @login_required(login_url=”html page”)

 In this lecture , we will understand how to restrict access with the Django
login required decorator function? Where to use it? And all about it.

05/19/2024 Priya Singh Python web development with Django Unit III 63
Why Decorators?

Django provides several decorators that can be applied to views to support various HTTP features .
Decorators are an easy way to clean up your code and separate the view
authentication process from the view functionality. Django has several useful built-
in decorators such as @login_required, @permission_required for user permissions
and @require_http_methods for restricting request methods (GET|POST).

05/19/2024 Priya Singh Python web development with Djan 64


go Unit III
Login Functionality Test and Logout

 Exaplaining Django Login and Logout. Django is a High-Level Web Framework and it has
lots of built-in features. We can use those built-in functions for our common use of Web
Application. Some of the functions are Permission and User Control, Signals, Templates,
Django ORM, Access Control List, etc. Out of this Registration App, is a good example and
a good thing about it is that the features can be used out-of-the-box.

 With the Authentication Views, you can take advantage of the following features

1. Login
2. logout
3. User Registration
4. Change Password
5. Reset Password or Forgot Password

05/19/2024 Priya Singh Python web development with Django Unit III 65
Login Functionality Test and Logout

05/19/2024 Priya Singh Python web development with Django Unit III 66
Login Functionality Test and Logout

05/19/2024 Priya Singh Python web development with Django Unit III 67
Login Functionality Test and Logout

05/19/2024 Priya Singh Python web development with Django Unit III 68
Daily Quiz

1. Discuss Django Authentication System.


2. What is the role of frameworks in python.
3. Discuss any three frameworks.
4. Discuss about , Security Problem & Solution with Django .
5. Discuss implementation rule of Falcon.
6. Discuss the Zappa framework.
7. Discuss the role of Dash.
8. Discuss the application area of cherryPy.
9. Discuss about the Request Http methods in Python.
10. Discuss about Flask application.

Priya Singh Python web development with Django Unit III


05/19/2024 69
Weekly Assignment

1. What are the most important uses of Django.


2. What are the disadvantages of Django?
3. What are the different data types used in Django.
4. What are the salient features of Django.
5. What are some of the technical features that Django includes

05/19/2024 Priya Singh Python web development with Django Unit III 70
Topic Link ( YouTube & NPTEL Video Links)

YouTube /other Video Links


• https://youtu.be/eoPsX7MKfe8?list=PLIdgECt554OVFKXRpo_kuI0XpUQKk0ycO

• https://youtu.be/tA42nHmmEKw?list=PLh2mXjKcTPSACrQxPM2_1Ojus5HX88ht7

• https://youtu.be/8ndsDXohLMQ?list=PLDsnL5pk7-N_9oy2RN4A65Z-PEnvtc7rf

• https://youtu.be/QXeEoD0pB3E?list=PLsyeobzWxl7poL9JTVyndKe62ieoN-MZ3

• https://youtu.be/9MmC_uGjBsM?list=PL3pGy4HtqwD02GVgM96-V0sq4_DSinqvf

05/19/2024 Priya Singh Python web development with Django Unit III 71
MCQ s
1. What is a Django App? 2. Django was introduced by
ADjango app is an extended package with base package
is Django A. Adrian Holovaty
B. Django app is a python package with its own B. Bill Gates
components. C. Rasmus Lerdorf
C. Both 1 & 2 Option D. Tim Berners-Lee
D. All of the above
3. What are Migrations in Django
A. They are files saved in migrations directory.
B. They are created when you run make migrations
command.
C. Migrations are files where Django stores changes to
your models.
D. All of the above

4. Which architectural pattern does django follow


APHP
B. MVT
C. HTML
D. None of the above
Priya Singh Python web development with Django Unit III
05/19/2024 72
MCQ s

which of these is not a valid backend for caching in django


A. Django.core.cache.backends.sys.memory
B. django.core.cache.backends.db.DatabaseCache
C. django.core.cache.backends.locmem.LocMemCache
D. None of the above

5. Which architectural pattern does django follow


A.PHP
B. MVT
C. HTML
D. None of the above

05/19/2024 Priya Singh Python web development with Djan 73


go Unit III
MCQ s
6. Python is a : 7. Python is Case Sensitive when dealing with
Development environment Identifiers?
Set of editing tools Yes
Programming Language No
Sometimes Only
None Of the Above

8. What is the OUTPUT of the following Statement? 9. What is the OUTPUT when the following
print 0xA + 0xB + 0xC : Statement is executed?
0xA0xB0xC “abc”+”xyz”
33 abc
ABC abcxyz
000XXXABC abcz
abcxy

10.what is the type of a? a={1,2:3} list


set
dict
syntax error

Priya Singh Python web development with Django Unit III


05/19/2024 74
Glossary Questions
Top 10 design pattern interview questions

1. Explain Django Architecture?


2. Explain the Django project directory structure?
3. What are models in Django?
4. What are templates in Django or Django template language?
5. What are views in Django?
6. What is Django ORM?
7. What is Django Rest Framework(DRF)?
8. What is the difference between a project and an app in Django?
9. What are different model inheritance styles in the Django?
10.What are Django Signals?
05/19/2024 Priya Singh Python web development with Django Unit III 75
Expected Questions for University Exam
Top 10 design pattern interview questions

1. Explain Django Architecture?


2. Explain the Django project directory structure?
3. What are models in Django?
4. What are templates in Django or Django template language?
5. What are views in Django?
6. What is Django ORM?
7. What is Django Rest Framework(DRF)?
8. What is the difference between a project and an app in Django?
9. What are different model inheritance styles in the Django?
10.What are Django Signals?
Priya Singh Python web development with Django Unit
05/19/2024 76
III
Summary

Till Now we understand The idea of this module Introduction to


Django Authentication System To prove someone is who they say
they are, they must provide a password when creating an account,
and again at any time they want to authenticate themselves. This
should be familiar: you go through this kind of workflow any time
you sign up for a service like Twitter or Netflix. Django is widely
lauded for its ease-of-use and pragmatic design, but like all
software it is susceptible to its own share of critical vulnerabilities.
Django's open source popularity means that default attack vectors
are also widely known.

05/19/2024 Priya Singh Python web development with Django Unit III 77
References
(1) Tom Aratyn, “Building Django 2.0 Web Applications: Create enterprise-grade, scalable
Python web applications easily with Django 2.0”, 2nd Edition 2018, Packt Publishing.

(2) Nigel George, “Build a website with Django”, 1st Edition 2019, GNW Independent
Publishing Edition.

(3) Ray Yao,” Django in 8 Hours: For Beginners, Learn Coding Fast!, 2nd Edition 2020,
Independently published Edition.

(4) Harry Percival, “Test-Driven Development with Python: Obey the Testing Goat: Using
Django, Selenium, and JavaScript”, 2nd Edition 2019, Kindle Edition.

05/19/2024 Priya Singh Python web development with Django Unit III 78
THANK YOU

05/19/2024 Priya Singh Python web development with Django Unit III 79

You might also like