2014-05-14 4 views
1

나는 오류장고 NoReverseMatch URL이 문제

"Reverse for 'recall' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'associate/recall/']" 

을 얻고있다. 여기 내 HTML입니다 :

<form action="{% url 'associate:recall' ordered_group %}" method="post"> 
     {% csrf_token %} 

     <div> 
      <label for="recall">enter as many members of {{ ordered_group }} as you can recall </label> 
      <input type="text" id="recall" name="recall"> 
     </div> 
     <div id="enter_button"> 
      <input type="submit" value="enter" name="enter" /> 
     </div> 
     <div id="done_button"> 
      <input type="submit" value="done" name="done" /> 
     </div> 
    </form> 

"ordered_group"는 '배우'보기에서 이월 된 모델 객체입니다

urls.py :

urlpatterns = patterns('', 
    url(r'^learn/', "associate.views.learn", name='learn'), 
    url(r'^recall/', 'associate.views.recall', name='recall'), 
    url(r'^$', "associate.views.index", name='index'), 
) 

내가 노력하고 있어요 학습 뷰 컨텍스트에서 html로 제출 된 ordered_group 모델 객체를 사용하여 다시 호출 뷰를 인수로 사용합니다. 이것을 할 수 있습니까? 그것은 나에게 의미가 있지만, 이것을하는 올바른 방법은 무엇입니까?

views.py

def recall(request, ordered_group): 
    ... 


def learn(request): 
... 
ordered_group = ordered_groups[index] 

return render(request, 'associate/learn.html', {'dataset':model, 'ordered_group':ordered_group}) 

내가

답변

3

당신에서 HTML, 당신은 일을 함께 양식을 제출하려면 :

{% url 'associate:recall' ordered_group %} 

장고는 "리콜"URL이 것으로 예상 "associate"네임 스페이스에서 ":"때문에. , 당신이 필요 "ordered_group"에 대해,

{% url 'recall' ordered_group %} 

을 그리고 : 그냥 할, 당신은 네임 스페이스를 원하지 않는 경우

url(r'^recall/', 'associate.views.recall', namespace='associate', name='recall') 

:하지만, 당신처럼, urls.py에서 네임 스페이스를 선언해야 같은 URL에 선언하는 : 당신은 HTML에 ordered_group 전달하는

url(r'^recall/(?P<ordered_group>\w+)', 'associate.views.recall', namespace='associate', name='recall') 

, 또한 현재는 views.py이 기대하지만, 당신은 당신이 URL에이 기대되지 않습니다.

+0

나는 당신의 제안을 시도했지만 그것이 문제라고 생각하지 않습니다. 나는 여전히 NoReverseMatch를 얻고 있지만 인수가있다 : " '('Unordered_Group : group1>, ') 인수와'{ ''인수가없는 '회수'에 대한 리버스 .0 패턴 시도 : [] "코드에서 다른 부분이 잘못 될 수 있다고 생각할 수 있습니까? –