I’m on a page with a variable url /emails/edit/32/, and I want to update the form and refresh the page…how do I issue an HttpResponseRedirect to the current page, which has a variable extension?
My urls.py is:
urlpatterns = patterns('',
(r'^emails/edit/$', 'email_edit'), # this is the page it is re-directing to
(r'^emails/edit/(?P<email_id>\d+)/$', 'emails_single'),
)
And my views.py is:
def emails_single(request, email_id):
...(stuff)...
Email.objects.filter(id=request.POST['id']).update(email=request.POST['email'])
return HttpResponseRedirect(reverse('emails_single',args=[email_id]))
Update: what it is doing is just chopping off the ending of the URL (even when using the reverse examples). For example: http://127.0.0.1:8000/emails/edit/42/ –> http://127.0.0.1:8000/emails/edit/
1 Answer