1 from django.contrib import admin 2 from django.urls import path, include 3 4 urlpatterns = [ 5 path('admin/', admin.site.urls), 6 path('blog1/', include(('blog1.urls', 'a'), namespace='blogg')), #'a'可以为任意字符,但不能为空 7 ]
blog/urls.py:
1 from django.contrib import admin 2 from django.urls import path, include 3 4 urlpatterns = [ 5 path('admin/', admin.site.urls), 6 path('blog1/', include(('blog1.urls', 'a'), namespace='blogg')),#'a'可以使用任意字符,但不能为空 7 ]myblog/urls.py:
1 from django.urls import path 2 from . import views 3 urlpatterns = [ 4 path('', views.index), # 这是路由模式 5 path('article/<int:article_id>', views.article_page, name='article_detai'), # path中的组名必须和参数名一致 6 ]