SImon
SImon

Reputation: 859

How to have multiple get params in an URL?

I'm using Django to create a website, and in one portion I need two get requests in the url - one called "search", and one called "page". I've tried the following -

return HttpResponseRedirect('/explore/?search=test/?page=1')

However, '/?page=1' is being included as part of the search, and this is messing it up. Any way to keep them as two different gets, or will I have to fuse them into one?

Upvotes: 1

Views: 307

Answers (1)

Aamir Rind
Aamir Rind

Reputation: 39649

Do it like this:

return HttpResponseRedirect('/explore/?search=test&page=1')

and in view you can get both parameters as:

search = request.GET.get('search')
page = request.GET.get('page')

Upvotes: 4

Related Questions