Django URLs tutorial step by step

Brijpal Sharma
django python   Publish on:-September 16th, 2019 , Category:- Web Development

Today topic is how to configure URLs in Django. in this blog post, we learn how to create a link to redirect and handle user request to the server.

In this post, we learn all about URLs or routes in Django step by step. we know whenever user request for something we can handle using URLs. so set URLs for that user what we want to show a text message or a view using URL request in Django framework.

Open your

When you open by default you will find one URL.

from django.contrib import admin
from django.urls import path

urlpatterns = [

Step: 1 Create URL for about request

Here we write two lines of code first one is for import views and the second one is for URLs handle here I create a URL for hande a request for about

from django.contrib import admin
from django.urls import path
from . import views

urlpatterns = [
    path('about/', views.about, name=about),


Step: 2 Add new file to handle URL request

Create a new file and add some to code to response request.

from django.shortcuts import render

def about(request):
    return render(request, 'index.html')


Step: 3 create a new view HTML file

The best practice is before creating a view first create a directory named templates than create an HTML file named index.html.

Django URLs tutorial step by step

Now we have an about page add some code to view.

<!DOCTYPE html>
<html lang="en">
    <meta charset=UTF-8>
    <h1>I am about page</h1>


Step: 4 Update file for using templates

Here we going to tell python we are going to use a template file which is in templates folder so use this. 

Here just update 'DIRS' with folder name.

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [


Step: 5 run you python server to check your application

Django URLs tutorial step by step


So here we can see the result now we successfully completed tutorials on Django URLs tutorial step by step hope its help you.

Best of Luck

Brijpal Sharma

Hello, My Name is Brijpal Sharma. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of Codermen. I started this blog to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers...


You must be logged in to post a comment.