7.7. Views URLs

7.7.1. Global URLs

7.7.2. In app URLs

7.7.3. urlpatterns

Code 7.4. Path usage
# doctest: +SKIP_FILE

from django.conf import settings
from django.contrib import admin
from django.urls import path
from django.urls import include
import debug_toolbar

urlpatterns = [
    path('admin/', admin.site.urls),
    path('contact/', include(('contact.urls', 'contact'), namespace='contact')),
]

if settings.DEBUG:
    urlpatterns += [
        path('__debug__/', include(debug_toolbar.urls)),
    ]

7.7.4. path

Code 7.5. Path usage
# doctest: +SKIP_FILE
from django.urls import path
from shop.views import ListView, DetailView


urlpatterns = [
    path('<int:id>/', DetailView.as_view(), name='details'),
    path('', ListView.as_view(), name='list'),
]

7.7.5. url

Code 7.6. Path usage

7.7.6. include

Code 7.7. Path usage

7.7.7. URLs reversing

7.7.8. URLs in templates