Django url and GET request in template

I use the "url" tag in my template, and everything works fine, except that I cannot capture everything that is behind it. Since I have several filters on this page that are stored using a GET request in the URL, I should be able to access them. What happens when I select one filter, url will change to some / url /? F = 1, then when I select another filter, the previous filter will be overridden, since the URL is only some / url without a request.

Here is the part from urls.py:

url('^products/$', products_list, name = 'products_list'), 

Is there a way to change it so that the url tag captures the GET request? Or do I need to create a filter that will add it there?

Any help is appreciated

Hi

+4
source share
1 answer

Cannot create query string using url tag. If you need to add a query string to the output, do it manually, for example. {% url foo bar %}?var={{ val|urlencode }} .

+5
source

Source: https://habr.com/ru/post/1309808/


All Articles