2013-01-22 81 views
0

表單數據我有一個簡單的表格保存從純HTML到數據存儲

<form name="input" action="" method="get"> 
Username: <input type="text" name="user" id = "xxx"> 
<input type="submit" value="Submit"> 
</form> 

在view.py我想要寫一個函數來獲取值用戶輸入

def add(request): 
if request.method =="POST": 
     abc=request.args.get('xxx') 

return render_to_response('myapp/addtour.html') 

但事實並非如此工作。請告訴我如何在Google App Engine或Django中執行此操作

回答

4

1:您在表單使用GET時檢查POST - if塊永遠不會觸發。

2:xxx是一個HTML ID - 它與GET/POST無關。名稱參數確實。所以request.GET.get('user') - 不是'xxx'