Reputation: 53
I want to pass a string, in the url, and then catch in in the view
<a href="{% url 'dolgozo:dolgozo-detail' orderby=nev %} ">
I want to pass "nev" string.
url(r'^orderby=(?P<nev>.+)$', login_required(DolgozokListView.as_view(template_name="DolgozoKarbantart/DolgozokList.html")), name='dolgozo-detail'),
What is the regex for this, and how can i catch it in the view?
Upvotes: 1
Views: 1127
Reputation: 37846
html, no need for /
before ?
<a href="{% url 'dolgozo:dolgozo-detail' %}?orderby={{ nev }}">
urls.py
url(r'^orderby/$', login_required(DolgozokListView.as_view(template_name="DolgozoKarbantart/DolgozokList.html")), name='dolgozo-detail'),
views.py
orderby = request.GET.get('orderby')
Upvotes: 2
Reputation: 10305
Why not try the simple one...
HTML
<a href="{% url 'dolgozo:dolgozo-detail' %}/?orderby={{ nev }}">
URL
url(r'^orderby/$', login_required(DolgozokListView.as_view(template_name="DolgozoKarbantart/DolgozokList.html")), name='dolgozo-detail'),
And in the view simply get the orderby
using GET
orderby = request.GET.get('orderby')
Upvotes: 3