Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append a querystring to URL in django

Tags:

django

I have a function that calls another function and passes a query string to the end of the URL.

How would I accomplish the following --

if my_videos:     return render(request, template, {kwargs}) + "?filter=others&sort=newest" 

Note: I do not care if I use render or not, its use is merely to point out what I'm trying to accomplish. Thank you.

like image 766
David542 Avatar asked Aug 15 '11 01:08

David542


People also ask

What is Querystring in URL?

On the Internet, a querystring (also called an HTTP querystring) is part of the set of characters automatically input in the address bar of a dynamic Web site when a user makes a request for information according to certain criteria.

How do I pass Querystring?

To pass in parameter values, simply append them to the query string at the end of the base URL. In the above example, the view parameter script name is viewParameter1.

How do I pass URL parameters in Django?

Django URL pass parameter to view You can pass a URL parameter from the URL to a view using a path converter. Then “products” will be the URL endpoint. A path converter defines which type of data will a parameter store. You can compare path converters with data types.


1 Answers

Pass the query string in the template:

<a href="{% url 'my_videos' %}?filter=others&sort=newest">My Videos</a> 
like image 153
David542 Avatar answered Sep 29 '22 18:09

David542