我真的很困惑为什么我的网址调度程序与此网址不匹配
http://127.0.0.1:8000/2011/jun/26/third-entry/
这是我的主要网址调度员的样子
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^blog/', include('djangoblog.blog.urls')),
)
在我的博客文件夹中,我有另一个网址调度程序
urlpatterns = patterns('django.views.generic.date_based',
#regex is passed to object_detail which is the name of the generic view that will pull out a single entry
(r'^(?P<year>d{4})/(?P<month>[a-z]{3})/(?P<day>w{1,2})/(?P<slug>[-w]+)/$', 'object_detail', dict(info_dict, slug_field='slug',template_name='blog/detail.html')),
)
我也没试过这个网址
http://127.0.0.1:8000/blog/2011/jun/26/third-entry/
我必须遗漏一些非常简单的事情......
答案 0 :(得分:3)
你的正则表达式错了。
(?P<year>d{4})
应为(?P<year>\d{4})
这同样适用于URI的其他部分:
(?P<day>\d{1,2})
(?P<slug>[-\w]+)