1.首先再新建得app下面创建一个url.py文件 专门装这个app所有功能得路由
from django.urls import path, re_path
from app1.views import *
urlpatterns = [
path('test/', test),
path('article/create/', article_create, name='article_create'),
# 动态路径书写方案
path('article/<int:article_id>/<str:title>/', article_read, name='article_read'),
]
2.总线得url嵌入一下 app模块得url include嵌入一下就可以模块化二级分块访问了
from django.contrib import admin
from django.urls import path, re_path, include
from app1.views import *
urlpatterns = [
path('admin/', admin.site.urls),
# 正则路径表达方式(正则匹配收集好)
re_path('^phone/(?P<phone_num>1[3456789]\d{9})/$', phone_number),
path('article/', include('app1.urls'))
]
|