正则路由
This commit is contained in:
parent
b9a3cad0a4
commit
c7aad21e87
@ -38,6 +38,10 @@ urlpatterns = [
|
||||
#http://localhost:8000/blog2/2025/4/26/80
|
||||
path('blog2/<int:year>/<int:month>/<int:day>/<int:id>', helloWorld.views.blog2),
|
||||
|
||||
# 正则路由
|
||||
# http://localhost:8000/blog3/2025/04/26
|
||||
re_path('blog3/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})', helloWorld.views.blog3),
|
||||
|
||||
# 媒体路由
|
||||
re_path('media/(?P<path>.*)', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),
|
||||
]
|
||||
|
||||
@ -13,3 +13,6 @@ def blog(request, id):
|
||||
|
||||
def blog2(request, year, month, day, id):
|
||||
return HttpResponse(str(year) + '/' + str(month) + '/' + str(day) + '/' + ' id是' + str(id) + "的博客页面")
|
||||
|
||||
def blog3(request, year, month, day):
|
||||
return HttpResponse(str(year) + '/' + str(month) + '/' + str(day) + "的博客页面")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user