Reputation: 41
Now I'm making a web app with django. I want to put more than 2 query paramaters into my URL, but if I put some keywords into my search box and send them, the query paramater will show only these keywords. For example, current URL is like below. https://example.com/jobs?area=SYDNEY If I search something, it becomes below. https://example.com/jobs?query=something
This is not what I want. What I want is https://example.com/jobs?area=SYDNEY&query=something
How can I do it?
<form action="" method="get">
<input type="text" name="query" value="{{ request.GET.query }}"><input type="submit" value="Search">
</form>
Upvotes: 0
Views: 565
Reputation: 5257
You can use the same method you used to get the query value in your form to get the area value, then put it into a hidden field
<form action="" method="get">
<input type="text" name="query" value="{{ request.GET.query }}"><input type="submit" value="Search">
<input type="hidden" name="area" value="{{ request.GET.area }}">
<input type="submit" value="Search">
</form>
Now the hidden field is populated from the URL, and passed along as part of the form when it's submitted
Upvotes: 1