2013-03-03 4 views
0

내 URL은 다음 캡처 할 필요가 없습니다 :장고 : 여러 매개 변수에 역의 URL 경기는

domain/forum-name/ 
domain/forum-name/topic-name 

I가 다음 URL 정의 : I 도메인/이름과 같은 URL을 명중

url(r'^$', views.index_forums, name='index_forums'), 
url(r'^(?P<forum_name>[-\w]+)/(?P<topic_name>[-\w]+)/$', views.show_topic, name='show_topic'), 
url(r'^(?P<forum_name>[-\w]+)/$', views.index_topics, name='index_topics'), 

-of-forum, 나는 HTML에서 URL을 다음과 같이 생성한다 :

{% url 'board:show_topic' forum_name|lower topic.title|lower %} 

이렇게하면 "Reverse ... not found"오류가 나타나며 figu 이유를 되 찾으십시오. "url"을 잘못 사용하고 있습니까? 정규 표현식에 문제가 있습니까? 감사!

편집 : 전체 오류 및 템플릿을 추가 :

NoReverseMatch at /random/ 
Reverse for 'show_topic' with arguments '(u'random', u'funny youtube videos')' and keyword arguments '{}' not found. 
Request Method: GET 
Request URL: http://localhost:8000/random/ 
Django Version: 1.5c2 
Exception Type: NoReverseMatch 
Exception Value:  
Reverse for 'show_topic' with arguments '(u'random', u'funny youtube videos')' and keyword arguments '{}' not found. 
Exception Location: /Users/travis/code/penv/lib/python2.7/site- packages/django/template/defaulttags.py in render, line 424 
Python Executable: /Users/travis/code/penv/bin/python 
Python Version: 2.7.2 

Reverse for 'show_topic' with arguments '(u'random', u'funny youtube videos')' and keyword arguments '{}' not found. 
1 {% extends "board/base.html" %} 
2 
3 {% block content %} 
4 {% if topic_list %} 
5 <ul> 
6 {% for topic in topic_list %} 
7  <li><a href="{% url 'board:show_topic' forum_name|lower topic.title|lower %}">{{topic.title}}</a></li> 
8 {% endfor %} 
9 </ul> 
10 {% else %} 
11 <p>No topics! <a href="/topic/new/">Make a new one</a>.</p> 
12 {% endif %} 
13 {% endblock %} 
+0

전체 오류 텍스트를 게시 할 수 있습니까? – czarchaic

+0

보기를 게시 할 수 있습니까? –

+0

원래 게시물에 추가 – c4am95

답변

2

시도 :

{% url 'show_topic' forum_name|lower topic_name|lower %} 

편집 :

귀하의 URL 정규식에 동의하지 않는 공간 :

시도 :

url(r'^(?P<forum_name>[-\w]+)/(?P<topic_name>[-\w\ ]+)/$', views.show_topic, name='show_topic'), 
+0

아무 것도 변경하지 않습니다. 나는 응용 프로그램의 네임 스페이스가 이렇게 : url (r '^', include ('board.urls', namespace = "board")), – c4am95

+1

어떤 버전의 장고를 사용하고 있습니까? 일부 버전에서는 명명 된 URL에 따옴표를 사용할 수 없습니다. –

+0

1.5에 안정적입니다. – c4am95

관련 문제