我的网址是这样的......
/eng/blog/site-news/
出现的错误看起来像这样......
^admin/
^(?P<page_lang>\w+)/blog/
^(?P<page_lang>\w+)/blog/
^(?P<page_lang>\w+)/blog/
^$
^(?P<category>\w+)/$
^(?P<category>\w+)/post/(?P<post_title>\w+)/$
我以前做过这件事并且从未遇到过这个问题,它必须是我看不到的小东西
urls.py#1
url(r'^admin/', include(admin.site.urls)),
url(r'^(?P<page_lang>\w+)/blog/', include('blog.urls')),
url(r'^blog/', include('blog.urls')),
url(r'^comments/', include('django_comments.urls')),
url(r'^', include('main.urls')),
urls.py#2
url(r'^$', 'blog.views.main_page'),
url(r'^(?P<category>\w+)/$', 'blog.views.category_page'),
url(r'^(?P<category>\w+)/post/(?P<post_title>\w+)/$', 'blog.views.post_page'),
答案 0 :(得分:3)
\w
匹配数字,字母和_
;你需要加入-
:
^(?P<category>\w+)/post/(?P<post_title>[-\w]+)/$
答案 1 :(得分:1)
或除/
^(?P<category>\w+)/post/(?P<post_title>[^/]*)/$