错误消息是:
Using the URLconf defined in Blog.urls,
Django tried these URL patterns, in this order:
^admin/doc/
^admin/
^post/ ^post/(?P<post_id>\d+)/$
The current URL, post/1458/, didn't match any of these.
为什么呢?我认为post/1485/
匹配^post/(?P<post_id>\d+)/$
我的根网址配置为:
urlpatterns = patterns('',
...
url(r'^post/', include('posts.urls')),
)
然后,我的posts/urls.py
是:
urlpatterns = patterns('',
...
url(r'^post/(?P<post_id>\d+)/$', 'post.views.post_page'),
)
答案 0 :(得分:8)
您当前的设置会匹配以下网址:
/post/post/1485/
让posts/urls.py
看起来像:
urlpatterns = patterns('',
...
url(r'^(?P<post_id>\d+)/$', 'post.views.post_page'),
)