Routing - zamaniamin/python GitHub Wiki
Django routing info is store in <project_name>/urls.py
file.
the include()
method allow to link another urls.py
file.
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls), # pre-created admin urls routes
path('', include('<app_name>.urls')) # include your app urls
]
and in your app directory <app_name>/urls.py
from django.urls import path
from . import views
url patterns = [
path('posts', views.index, name='posts.index'),
path('posts/create/', views.create, name='posts.create',
path('posts/<int:id>/', views.show, name='posts.show'),
path('posts/<int:id>/edit/', views.edit, name='posts.edit'),
path('posts/<int:id>/delete/', views.delete, name='posts.delete'),
]
from django.conf import settings
from django.conf.urls.static import static
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)