[Answer]-Redirect to paginated page after form submit – Django

1👍

I think the page parameter should be in the request.path, so try appending this to the submit action in the template:

?next={{request.path}}

and make sure you have request as a template context processor in your settings.py file.
(See https://stackoverflow.com/a/1711592/837845 for details)

0👍

So to everyone struggling with redirecting to paginated page what i did was first for view of main page i store this page’s pagination in session:

    request.session['previous_page'] = request.path_info + "?page=" + request.GET.get("page", '1')

Now in view that receives POST request from form return HttpResponseRedirect:

return HttpResponseRedirect(request.session['previous_page'])
👤Esgath

Leave a comment