URL Configuration in Python
From the Django cheat sheet · Views & URLs · verified Jul 2026
URL Configuration
URL patterns and routing
python
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('products/', views.ProductListView.as_view(), name='product_list'),
path('products/<slug:slug>/', views.product_detail, name='product_detail'),
]💡 Use app_name for URL namespacing
📌 Path converters: str, int, slug, uuid
⚡ Include trailing slashes consistently
🟢 Use reverse() for maintainable URLs