URL mapping in Django works by mapping a URL pattern to a view. A view is a Python function that takes a web request and returns a web response.
For example, if you have a URL like ‘/articles/’, you can map it to a view called ‘articles_view’. This view would be responsible for handling the request and returning the appropriate response.
In Django, you would do this by adding a URL pattern to your project’s urls.py file:
urlpatterns = [
path(‘articles/’, views.articles_view, name=’articles_view’),
]
In this example, ‘articles_view’ is the name of the view we want to map to the URL ‘/articles/’. When a request is made to this URL, Django will call the ‘articles_view’ view and return the response.