djangodjango-templates

Is it possible to pass query parameters via Django's {% url %} template tag?


I'd like to add request parameters to a {% url %} tag, like ?office=foobar.

Is this possible? I can't find anything on it.


Solution

  • No, because the GET parameters are not part of the URL.

    Simply add them to the end:

    <a href="{% url myview %}?office=foobar">
    

    For Django 1.5+

    <a href="{% url 'myview' %}?office=foobar">