Author Profile Altaf Shaikh
Altaf Shaikh

BE Engg | Python Dev | Content Writer | Founder of TeachMeBro | Blockchain Dev | Django

Django- URLs

February 13th 2020   1233

What are Django URLs?
What are Django URLs?

In this tutorial, we will learn what are URLs in Django and how to create them and link them with the view functions that we have created in file.

So in our previous TUTORIAL, we have successfully created our Templates. Let's create URLs for each view Functions which is the last step to render our Html templates to display them in the browser.

Django URLs

We want to access Signup view via a URL. Django has his own way for URL mapping and it's done by editing your project file (social/

When a user makes a request for a page on your web app, Django controller takes over to look for the corresponding view via the file, and then return the HTML response or a 404 not found error, if not found. In, the most important thing is the "urlpatterns" tuple. It’s where you define the mapping between URLs and views. A mapping is a tuple in URL patterns, the file looks like −

from django.contrib import admin
from django.urls import path
from django.conf.urls import url
from account import views as acccount_views

urlpatterns = [
    url(r"^$", acccount_views.IndexView.as_view(), name="index"),
    url(r"^signup/$", acccount_views.signup, name="signup"),

add this line in the bottom of social/


Now run the following command where the file is located:

python runserver


You will see the home page click on the signup button to go to the Signup page.

Fill the form and if everything is alright then you will we redirected to the home page as logged in user.

Congratulation! We have successfully implemented the signup view in Django.