Reputation: 6184
We recently upgraded from Django 1.9 to 1.10, and now the following problem appeared:
urls.py:
url(r'^search/(?:\?q=(?P<q>[^&]*))?$', views.search, {'q': ''}, name='search'),
Template:
<a href="{% url 'issues:search' "foobar" %}">Issues</a>
With Django 1.9, the result was
https://127.0.0.1/issues/search/?q=foobar
Since Django 1.10, this results in the following URL:
https://127.0.0.1/issues/search/%3Fq=foobar
As a result, links that contain query parameters do not work anymore. How can this be made to work with Django 1.10?
Upvotes: 0
Views: 851
Reputation: 599866
Django URL patterns do not include querystring parameters, and this is not new since 1.10 but has always been the case. You should not include it in the pattern, and add it separately in the link itself.
url(r'^search/$', views.search, name='search'),
...
<a href="{% url 'issues:search' %}?q=foobar">
Upvotes: 2