0
我對Python和Django很新。我正嘗試重定向到第二個視圖函數。這裏是我的URL配置:NoReverseMatch與重定向在Django
urlpatterns = patterns('dept.pv.verif.views',
(r'^apps/dept/pv/verif/$', 'index', {}, 'index'),
(r'^apps/dept/pv/verif/display$', 'display', {}, 'display'),
(r'^apps/dept/pv/verif/display/(?P<action>\w{1})/(?P<id>\w{8})/$', 'display', {}, 'display'),
url(r'^apps/dept/pv/verif/display/(?P<action>\w{1})/(?P<id>\w{8})/$', 'display', name='display'),)
這裏是我的看法功能:
def index(request):
context = {}
visit_switch = request.GET.get('visit_switch')
if not visit_switch:
id_form = Enter_ID()
else:
id_form = Enter_ID(request.GET)
if id_form.is_valid():
return redirect('display', action='R', id='test')
context['id_form'] = id_form
return render_to_response('index.html', {'context':context})
與第二:
def display(request, action, id):
# ...
return render_to_response('index.html')
我得到一個NoReverseMatch錯誤。我不明白爲什麼重定向行與我的某個網址不匹配。我希望你能提供任何幫助。