1

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?

2 Answers 2

3

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')
Sign up to request clarification or add additional context in comments.

4 Comments

Page not found (404) Request Method: GET Request URL: localhost:58487/dolgozo/orderby/?orderby= Using the URLconf defined in MINY_Django.urls, Django tried these URL patterns, in this order: ^$ [name='login'] ^logout/$ [name='logout'] ^index/$ [name='index'] ^dolgozo/ ^orderby=(?P<nev>.+)$ [name='dolgozo-detail'] ^dolgozo/ ^orderby$ [name='dolgozo-detail'] ^dolgozo/ ^update/(?P<pk>\d+)$ [name='dolgozo-update'] ^dolgozo/ ^create/$ [name='dolgozo-create'] ^dolgozo/ ^delete/(?P<pk>\d+)$ [name='dolgozo-delete'] ^felhasznalo/ ^dolgozomunkakor/ ^munkaidoadat/ ^munkakor/
There is an error with URL... I updated that pls check now
it's the same, with double slashes : localhost:62003/dolgozo/orderby//?orderby=
I've figured it out. You dont need that url,and everything is fine.
2

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')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.