What is Django URL Patterns | Complete Django Tutorials

Django URL patterns copy
Django Django Tutorials

What is Django URL Patterns | Complete Django Tutorials

What are Django URL Patterns | Django Tutorials

We are publishing a new tutorial while learning Django, If you are looking for a good and explained discussion and answer of questions what are Django URL patterns and their different style and use then read this article from start to end.

URL is the uniform resource locator, we used the different words while learning Django as URL, URL Pattern, URLconf, URL Dispatcher, etc. We will learn all these terms, you will be cleared everything if you confuse. So, today we have to discuss Django URL patterns. How you can create a URL pattern for views mapping.

Actually, it is the mapping, that we need to make between URL and views. When we create views (function base or class base), we have to map that view with a URL when creating. There are different parameters as we used in the URL pattern. We will discuss all parameters & their use in this Django tutorial.

What is URLconf

When finding its answer on the internet we found that “A URLconf is like a table of contents for your Django-powered Web site.” It means when we create different URLs in one tuple in the urls.py file, it is the URLconf because it is just like table content that is original data, used by someone. So All the URLs that we create in the tuple are the contents of the URL pattern called URLconf.

What is URL Dispatcher

Actually, it is the mapping  URLs to views function. As we have defined different URLs for different views then URL dispatch map URL to specific views function that we want. You have noticed when you hit the URL according to your definition in the urls.py file then a specific view function is called, why this called and other not. It is due to adding the view function name attribute in a URL pattern and It is the URL dispatch that maps both to each other. And work fine for users.


In the urls.py file, you have to define URL Django URL patterns which will map your views function. In the following example, I took a simple example of a URL pattern that we  will discuss in detail for your information

urlpatterns = [

path(‘users/, views.users, name=’users’),


urlpattern is the name of a list, which is the Python data type in which data is stored and List items are ordered, changeable, and allow duplicate values to store in it.

In the next, there are three arguments in the path function that are:

  • Pathname: It is the pathname, using that user hit the URL
  • View function reference: It is the function you want to run when its URL hit
  • Name attribute: It is the name of your path, that mostly used in Template while making URL in the URL tag

Syntax of Django URL Patterns

urlpatterns = [

path(‘users/, views.users, name=’users’),

path(‘posts/’, views.posts, name=’posts’),

path(‘post_detail/<int:id>/’, views.post_detail, name=’post_detal’),

path(‘post_edit/<int:id>/’, views.post_edit, name=’post_edit),

path(‘post_del/<int:id>/’, views.post_del, name=’post_del),


Importance of URL pattern

Without URL, you did not reach the web page. You have to must enter a unique address for any web page you want to display on the browser. So, that URL we have created in Django urls.py files. If you want to make  URLs for your different web page, you have to map with views code, you must give the reference of the code of that view for which you are creating URL. When any URL a user hits in the browser, then specific views function or class will be executed because we have mapped with that URL.


Sure, you have cleared today topic of Django URL patterns, which is very simple and easy to understand. Now it is your work to do practise to get experience. If you did not do that, you can work properly, because there is no benefit of just reading an article, but you have to implement all these concepts in your project.

If you use Facebook, Twitter, Pinterest, LinkedIn, or other social media platforms, then share this Django tutorial, if you share, more students will take the chance to learn.

After reading today’s topic, if you face any problem while reading, understanding please discuss it with us. If you have understood and have any relevant questions then please discuss with us in the following comment section

Recommended Django Tutorial for beginners

Complete Discussion on Django Forms Widget | Django Tutorials

ALL About Django Form Errors | Django Tutorials

How to Create Virtual Environment in Django

100% Perfect | How to install Django Step by Step

Leave your thought here

Your email address will not be published. Required fields are marked *

Recent Comments

  1. Push it to the limit cool Wolf! You are the best and you can do everything! It'll all work out very very very soon! https://www.samsung.com smkmkplobydlmcrjmzgvx 2396134 on Django Create superuser | Django Tutorial
  2. Thank you For your hard work over the years! For this, we give you the opportunity. https://google.com#1234567890 For more information, see the instructions. skfhjvkjsdjsrbhvbsrfhkis 9357930 on Django Create superuser | Django Tutorial
  3. Thank you For your hard work over the years! For this, we give you the opportunity. https://google.com#1234567890 For more information, see the instructions. skfhjvkjsdjsrbhvbsrfhkis 5948210 on Django Create superuser | Django Tutorial
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar

Get your Enrollment


Leave your details below and receive a discount coupon in your inbox