python - View is not receiving POST data from form -


my view not receiving of post data sending login form.

to test out submission, want output email field browser.

the output being returned view none

login.html

        <form action="/login_email/" method="post">             {% csrf_token %}             <div class="form-group">                 <label for="email">email address</label>                 <input type="email" class="form-control" id="email" placeholder="email">             </div>             <div class="form-group">                 <label for="email">password</label>                 <input type="password" class="form-control" id="password" placeholder="password">             </div>             <button type="submit" class="btn btn-info">submit</button>         </form> 

views.py

def login_email(request):  if request.method == 'post':     email = request.post.get('email')     password = request.post.get('password')      return httpresponse(email) 

there no name field in input tags.

change html this...please note name attribute input tag, that's important.

<form action="/login_email/" method="post">         {% csrf_token %}         <div class="form-group">             <label for="email">email address</label>             <input name="email" type="email" class="form-control" id="email" placeholder="email">         </div>         <div class="form-group">             <label for="email">password</label>             <input name="password" type="password" class="form-control" id="password" placeholder="password">         </div>         <button type="submit" class="btn btn-info">submit</button>     </form> 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -