Reputation: 1
I am very new to Python and Django. I am trying to redirect to a second view function. Here is my url configuration:
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'),)
And here are my view functions:
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})
and the second:
def display(request, action, id):
# ...
return render_to_response('index.html')
I'm getting a NoReverseMatch error. I don't understand why the redirect line is not matching up with one of my urls. I would appreciate any help you can offer.
Upvotes: 0
Views: 573
Reputation: 14081
This regular expression group:
(?P<id>\w{8})
Will only match something 8 characters long. If you're actually passing id='test'
, that would be your problem.
Upvotes: 1