Bin Chen
Bin Chen

Reputation: 63299

django: passing parameters in URLConf

I want to have this URL:

/weibo_login/?app=first

I want the URLConf to call my view function with parameters but I don't know how to write the URL dispatcher to pass 'app=first' to the view function. The original URLConf:

urlpatterns += patterns('',
(r'weibo_login/', 'weibo.views.mylogin'),

The view function:

def mylogin(request):

I want to pass 'app=first' to view function and eventually get a dictionary in that function, so that I can know every parameter passed in.

Any good suggestions?

Upvotes: 0

Views: 533

Answers (1)

rafek
rafek

Reputation: 635

In your view you should write sth like this:

def mylogin(request):
    app = request.GET.get('app')
    ...

URLconf stays same as you posted. Generally you don't handle GET parameters in URLconf - this is job for views.

Upvotes: 3

Related Questions