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

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…

5 days 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…

1 month 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.…

2 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…

2 months ago

Building And Implementing A Two Paged Web Application Using Django

Introduction In this article, we will build a pages app that has a homepage and…

2 months ago

Logical Steps On How To Create Your First App In Django

Introduction When you say you want to use Django, it means you want to build…

2 months ago