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
我不能硬編碼的參數,因爲我不知道它 –
您可以設置這些動態,以及像:HREF =「/儀表板/ WID = { {your value1}}&ref_url = {{equest.get_host}}&adpart = {{your value2}}「 –
但是,我將如何訪問這些值?它們只在url中可用 –