1
,我發現了錯誤Django的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})
我想與
我試過你的建議,我不認爲這是問題所在。我仍然得到一個NoReverseMatch,但現在帶有一個參數:「未找到帶有參數'(,)'和關鍵字參數'{}'的'召回'的倒退。 「你能想到代碼中的其他明顯區域可能會出錯嗎? –