如何將「render_to_response參數」傳遞給新視圖?Django:render_to_response到另一個視圖
def show_list(request, id):
try:
profile = request.user.get_profile()
list = Lista.objects.get(user_profile = profile)
except Lista.DoesNotExist:
c = {}
c.update(csrf(request))
titlepage = "ooops, you don't have a list YET! click on button to create one!"
c = {'profile' : profile, 'request' : request, 'titlepage' : titlepage}
return render_to_response('/profiles/list/create/',c,context_instance=RequestContext(request))
這最後一行不起作用,url/profiles/list/create /重定向到一個視圖create_list。
嗯,我知道我可以寫一些像重定向(/ profiles/list/create /)但是用這個我不能傳遞字典c。
在此先感謝
對我有什麼好的例子嗎? – cleliodpaula
我更新了我的答案。 –
雖然這是一個很好的提示,但它並沒有真正回答關於如何將參數傳遞到下一個視圖的問題。可以通過添加一個查詢部分到目標'Location:'來完成。我不知道是否有一個快捷方式來創建GET查詢 - 部分從字典'C',但'urlparse.urlunsplit'看起來很有前途... –