2013-04-15 213 views
0

這裏是我的HTML代碼:簡單的GET請求返回空

{% extends "base.html" %} 

{% block content %} 




<form class="form-horizontal" action="/application/" method="get"> 
    <div class="control-group"> 
     <label class="control-label" for="userid">User ID</label> 
     <div class="controls"> 
      <input type="text" id="userid" placeholder="Email"> 
     </div> 
    </div> 
    <div class="control-group"> 
     <label class="control-label" for="pass">Password</label> 
     <div class="controls"> 
      <input type="password" id="pass" placeholder="Password"> 
     </div> 
    </div> 
    <div class="control-group"> 
     <div class="controls"> 
       <input type="submit" class="btn" value="Sign in"> 
      <br> 
      <a href="forgot">Forgot password?</a> 
      <br> 
      <a href="change">Change password?</a> 
     </div> 

    </div> 

</form> 






{% endblock %} 

這是我在我看來功能:

def application(request): 
    print request.GET 
    message=[] 
    for key,value in request.GET: 
     message.append("%s:%s"%key,value) 
    return HttpResponse(message) 

這裏不管我怎麼輸入,我的「打印request.GET中」打印<QueryDict: {}>

我無法弄清楚如何調試。任何線索?

回答

2

關你輸入有name屬性,

name屬性是使用什麼來填充GET請求數據。

<input type="password" id="pass" name="pass" placeholder="Password">

以上將在request.GET

顯示了關鍵 name