Django- Reverse HTTP redirect with parameters

9 years ago

Here's how to, from a view, redirect to another URL passing parameters to it. For instance, to redirect the user to a certain page after login: return HttpResponseRedirect(reverse('dz_details', kwargs={'dz_id':dz.id})) This will lookup the 'dz_details' name in your urls.py file, which could be defined like so:

url(r'^details/(\d+)/$', views.dz_details, name='dz_details'), There is a simpler way to do it, if you don't want to use the parameters' names, but you have to know the order on which they appear in the method: return HttpResponseRedirect(reverse('dz_details', args=[ dz.id ]))