News

Building And Implementing A Blog App Using Django: User Authentication

Introduction

User Authentication policy is a very crucial process for every application and organization. It is a process used to identify verified users and allow them to access accounts and networks securely. It is a process in which you verify that someone who is attempting to access services and applications is who they claim to be which can be established in various ways such as entering a password into your laptop or phone or a PIN number into your ATM. So far, we have built a web application that uses forms but we are still missing a major piece of basically almost every web application which is: USER AUTHENTICATION.

Implementing this is famously hard. There are many security concerns so its not advisable to do it yourself but with the help of Django which comes with a powerful built-in user authentication system that we can use, its much more easier.

How does this work?

Whenever we create a new project, by default, Django installs the auth app which provides us with a User Object containing:

  • Username
  • Password
  • Email
  • first_name
  • last_name

We will then use the User Object to implement log in, log out and sign up in our blog application.

Log In

Django already provides us with a default view for login page via LoginView so all we have to do is add a url pattern for the auth system, a log in template, and a small update to our settings.py file.

First, we will update the blog_project/urls.py where we will place our log in and log out pages at the accounts/URL.

blog_project/urls.py

from django.contrib import admin

from django.urls import path, include

urlpatterns = [

path(‘admin/’, admin.site.urls),

path(‘accounts/’, include(‘django.contrib.auth.urls’)), # new

path(”, include(‘blog.urls’)),

]

Olamide Ayeni

Share
Published by
Olamide Ayeni

Recent Posts

What is Flask?

Introduction Python is a programming language that has a large sum of frameworks. One of…

5 days ago

Cloud Computing: How Cloud Computing Is Revolutionizing The IT Industry.

Introduction What is Cloud Computing? According to Wikipedia, Cloud Computing is a paradigm for enabling…

4 weeks ago

10 Reasons Why You Should Learn Python In 2025.

Introduction In the fast paced world of technology, learning a versatile and high-in-demand programming language…

1 month ago

Building And Implementing A Blog App Using Django: Adding Forms

Introduction In previous articles, we have learnt about Django, how it works and how we…

2 months ago

Building And Implementing A Blog App Using The Django Framework

Introduction In this article, we shall learn how to build and implement a blog app.…

3 months ago

Building And Implementing A Message Board App Using Django

Introduction In this article, we shall use a database for the first time to build…

3 months ago