Sign up for Free !!
World's first open source developer community with
Ticketing System
How to handle URLs in Django?
In order to handle URL in Django, django.urls module is used by the Django framework.
Given below is the urls.py file of the project, lets see how it looks:
// urls.py
from django.contrib import admin
from django.urls import path
urlpatterns = [
path(‘admin/’, admin.site.urls),
]
We can see that, Django has already mentioned a URL here for the admin. Function path takes the first argument as a route of string or regex type.
Argument view is a view function which is used to return a response (template) to the user.
Module django.urls contains various functions, path(route,view,kwargs,name) is one of those which is used to map the URL and call the specified view.
Please Login/Register to write your answer !!!
In order to handle URL in Django, django.urls module is used by the Django framework.
Given below is the urls.py file of the project, lets see how it looks:
// urls.py
from django.contrib import admin
from django.urls import path
urlpatterns = [
path(‘admin/’, admin.site.urls),
]
We can see that, Django has already mentioned a URL here for the admin. Function path takes the first argument as a route of string or regex type.
Argument view is a view function which is used to return a response (template) to the user.
Module django.urls contains various functions, path(route,view,kwargs,name) is one of those which is used to map the URL and call the specified view.