Django ReverseMatch错误

时间:2011-12-05 18:56:58

标签: django

嗨,我无法想出这一个。我的申请表中有网址:

from django.conf.urls.defaults import *
from journal import views
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
...     
url(r'^search/$', views.journal_search, name='journal_search'), 
...
) 

在我的观点中:

def journal_search(request):
if 'q' in request.POST:
    # search code
    ....
return render_to_response('journal_search_results.html',
            locals(),context_instance=RequestContext(request)) 

并在base.html中:

{% load i18n %}
<form id="searchform" action="{% url journal_search %}" method="POST">
{% csrf_token %}<fieldset class="search">
    <label for="search"></label> <input id="search" type="text" name="q" placeholder="{% trans 'Search' %}... ">
</fieldset>

知道我为什么会这样做:

 Reverse for 'journal_search' with arguments '()' and keyword arguments '{}' not found.

?非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

如果在shell中运行以下命令会怎样?有错误吗?

from django.core.urlresolvers import reverse
reverse('journal.views.journal_search')

如果它在shell中有效,那么反向可能实际上不是问题。