我試圖在SO使用的表單的Django中啓用緩衝的URL:example.com/id/slug。 我沒有問題,使slu,,並具有目前的形式設置URL:http://127.0.0.1:8000/articles/id/(例如。/ articles/1 /),並且工作正常。對應的URL模式是:在Django中啓用緩衝的URL
(r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
如果我更改URL模式:
(r'^(?P<slug>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
然後我收到以下eror,當我瀏覽到http://127.0.0.1:8000/articles/another-article/:
The current URL, articles/another-article/, didn't match any of these.
但是,如果我試試:
http://127.0.0.1:8000/articles/1/
我得到的錯誤:
No article found matching the query
最後,我希望能夠通過導航到一個aricle之一:
http://127.0.0.1:8000/articles/1/ or http://127.0.0.1:8000/articles/1/another-article/
是的,你錯過了實際slu re的正則表達式匹配。 – 2009-10-25 12:26:58