I have a url like this
http://127.0.0.1:8000/orders/?from=&to=&status=1
I have an button in that page to export all orders but if i have a status I need to send this as an parameter in that url to filter before export
<a href="{% url 'orders:export' %}">Export</a>
How can I send parameters to that export function
CodePudding user response:
You can simply append your query string after url as follows
<a href="{% url 'orders:export' %}?from=&to=&status=1">Export</a>
CodePudding user response:
Your need to HTML encode the string in the href so:
<a href="{% url 'orders:export' %}?from=&to=&status=1">Export</a>
if you want to pass values of variables to the parameters, you use the |urlencode template tag [Django-doc]:
<a href="{% url 'orders:export' %}?from={{ from|urlencode }}&to={{ to|urlencode }}&status={{ status|urlencode }}">Export</a> 