Beginner
What is the role of Django's URL dispatcher?
The URL dispatcher in Django maps URLs to views, determining how different URLs are handled in your web application. It uses regular expressions to match URLs.
To set up URL routing:
- Define URL patterns in the
urls.py
file. - Map each URL pattern to a corresponding view function.
- Include namespace for better organization.
Example URL mapping:
from django.urls import path
from .views import home
urlpatterns = [
path('', home, name='home'),
]