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
Post a Comment