장고에서 SO가 사용하는 형태의 장황한 URL을 사용하려고합니다 : example.com/id/slug. 슬러그를 활성화하는 데 아무런 문제가 없으며 URL은 현재 http://127.0.0.1:8000/articles/id/ (예 :/articles/1 /) 형식으로 설정되어 있으며 정상적으로 작동합니다. 해당 URLPATTERN은 다음과 같습니다Django에서 부적절한 URL을 활성화하십시오.
(r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
난에 URL 패턴을 변경하는 경우 :
내가 http://127.0.0.1:8000/articles/another-article/로 이동하면(r'^(?P<slug>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
가 그럼 난 다음 eror을받을 :
The current URL, articles/another-article/, didn't match any of these.
경우에는, 그러나, 시도 :
http://127.0.0.1:8000/articles/1/
나는 오류 얻을 : 내가 통해 aricle를 탐색 할 수 있도록하려면 궁극적으로
No article found matching the query
을 중 하나를
http://127.0.0.1:8000/articles/1/ or http://127.0.0.1:8000/articles/1/another-article/
예, 실제 슬러그에 대한 정규식 패턴 일치가 누락되었습니다. –