How to handle URLs in Django?

Submitted 3 years, 5 months ago
Ticket #282
Views 241
Language/Framework Django
Priority Low
Status Closed

How to handle URLs in Django?

Submitted on Nov 02, 20
add a comment

1 Answer

Verified

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.

Submitted 3 years, 5 months ago


Latest Blogs