URL路由配置
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('page/2003/',views.page_2003_view),
path('',views.index_view),
path('page/1/',views.page_1_view),
path('page/2/',views.page_2_view),
]
Path转换器
语法:<转换器类型:自定义名>
path('page/<int:pn>',views.page_n_view),
path('<int:n>/<str:op>/<int:m>', views.cal_view)
函数 re_path(route, view, kwargs=None, name=None)
re_path(r'^(?P<x>\d{1,2})/(?P<op>\w+)/(?P<y>\d{1,2})$',views.cal2_view),
re_path(r'^birthday/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})$',views.birthday_view),
re_path(r'^birthday/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<year>\d{4})$',views.birthday_view)
|