How to handle URLs in Django?

To handle URL, django.urls module is used by the Django framework.

Let’s open the file urls.py of the project and see the what it looks like:

// urls.py

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

urlpatterns = [
path(‘admin/’, admin.site.urls),
]
See, Django already has mentioned a URL here for the admin. The path function takes the first argument as a route of string or regex type.

The view argument is a view function which is used to return a response (template) to the user.

The django.urls module contains various functions, path(route,view,kwargs,name) is one of those which is used to map the URL and call the specified view.