Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a redirect and keep the query string?

I want to make a redirect and keep what is the query string. Something like self.redirect plus the query parameters that was sent. Is that possible?

like image 366
Niklas Rosencrantz Avatar asked May 13 '12 06:05

Niklas Rosencrantz


2 Answers

newurl = '/my/new/route?' + urllib.urlencode(self.request.params)
self.redirect(newurl)
like image 175
Steven Almeroth Avatar answered Oct 23 '22 02:10

Steven Almeroth


You can fetch the query string to the current request with self.request.query_string; thus you can redirect to a new URL with self.redirect('/new/url?' + self.request.query_string).

like image 32
Nick Johnson Avatar answered Oct 23 '22 03:10

Nick Johnson