开发者

Why is my Django URL Dispatcher not working?

开发者 https://www.devze.com 2023-03-16 05:38 出处:网络
I\'m really confused as to why my URL dispatcher is not matching this url http://127.0.0.1:8000/2011/jun/26/third-entry/

I'm really confused as to why my URL dispatcher is not matching this url

http://127.0.0.1:8000/2011/jun/26/third-entry/

This is what my main url dispatcher looks like

urlpatterns = patterns('',
    (r'^admin/', include(admin.site.urls)),
    (r'^blog/', include('djangoblog.blog.urls')),
)

And inside my blog folder I have another url dispatcher

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')),
)

I also tried this url with no luck

http://127.0.0.1:8000/blog/2011/jun/26/third-entry/

I must be missing something r开发者_StackOverflow中文版eally simple...


Your regexp is wrong.

(?P<year>d{4}) should be (?P<year>\d{4})

The same applies to the other parts of the URI:

  • (?P<day>\d{1,2})
  • (?P<slug>[-\w]+)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号