2

I want a django url to look like this:

event/1?type=fun

so far I have:

url(r'^events/(?P<event_id>[\w\-]+)/(?P<event_code>[\w\-]+)/$', views.web_event)

which would be:

 events/1/fun

what is the technique for changing it to parameters?

1 Answer 1

6

You are confused of GET parameter with django url parameters. The parameter after ? is an http request QueryString that exists way before django does. You cannot control that with django url definition.

Django doc about GET and POST.

Wiki about query string.

Edit:

As I stated above, it's a GET parameter not a POST parameter, so if you want to use it in your views, you should fetch it from request.GET:

var = request.GET.get('q')
Sign up to request clarification or add additional context in comments.

2 Comments

Sorry I don't understand your question. You are already changed it into a parameter called event_code in your url definition, what else are you looking for?
if my link is localhost/url/?q=3, in django would I use request.POST.get('q') to return 3?

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.