📜  django slug int url 映射 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:00.993000             🧑  作者: Mango

代码示例1
# in views define the int slugs then the url mapping is like this

from django.urls import path, re_path

from . import views

urlpatterns = [
    path('articles/2003/', views.special_case_2003),
    re_path(r'^articles/(?P[0-9]{4})/$', views.year_archive),
    re_path(r'^articles/(?P[0-9]{4})/(?P[0-9]{2})/$', views.month_archive),
    re_path(r'^articles/(?P[0-9]{4})/(?P[0-9]{2})/(?P[\w-]+)/$', views.article_detail),
]