错误信息是:
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+)/$
我的根 url 配置是:
urlpatterns = patterns('',
...
url(r'^post/', include('posts.urls')),
)
然后,我的posts/urls.py
是:
urlpatterns = patterns('',
...
url(r'^post/(?P<post_id>\d+)/$', 'post.views.post_page'),
)
最佳答案
您当前的设置将匹配这样的 URL:
/post/post/1485/
使 posts/urls.py
看起来像:
urlpatterns = patterns('',
...
url(r'^(?P<post_id>\d+)/$', 'post.views.post_page'),
)
关于python - Django URL 与任何 URL 配置都不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11980110/