2014-01-28 66 views
0

我有一個頁面drag.html這是在該網址提供 http://localhost:8000/dashboard?wid=ca1480f&ref_url=localhost&adpart=left此頁面的其他參數有一個鏈接Django的通行證從一個鏈接到另一個視圖

<a id="btn-start" href="/dashboard/save" class="btn">Save Reward</a> 

當用戶點擊這個鏈接會重定向到一個SaveRewardview在這裏我要保存所有出現在鏈接的信息,即wid=ca1480f&ref_url=localhost&adpart=left

urls.py

url(r'^dashboard$', login_required(CouponPageView.as_view()), name='dashboard'), 
url(r'^dashboard/save$', login_required(SaveRewardView.as_view()), name=''), 

model.py

class SaveReward(models.Model): 
    widget = EmbeddedModelField(Widget) 
    campaign = EmbeddedModelField(Campaign) 
    coupon_part = models.CharField(max_length=200) 
    saved_on = models.DateTimeField(auto_now_add=True) 

def __unicode__(self): 
    return self.widget.widget_name 

Views.py

class SaveRewardView(TemplateView): 

    #Here how i will get wid , ref_url, adpart which is present in url parameters 

回答

0

您可以直接給出參數,在這樣的URL。

<a id="btn-start" href="/dashboard/?{{request.META.QUERY_STRING}}" class="btn">Save Reward</a> 

網址是:

url(r'^dashboard/$', login_required(CouponPageView.as_view()), name='dashboard'), 
+0

我不能硬編碼的參數,因爲我不知道它 –

+0

您可以設置這些動態,以及像:HREF =「/儀表板/ WID = { {your value1}}&ref_url = {{equest.get_host}}&adpart = {{your value2}}「 –

+0

但是,我將如何訪問這些值?它們只在url中可用 –

相關問題