python - Django login does nothing -


i'm using django's pre-packaged login, , reason, refreshes page, without login in, , without giving me of messages have set in view.

here html:

     <div class="col-md-9 col-md-offset-2" style="background-color: white; margin-top:10px; border-radius: 8px;">           {% if message %}           <b>{{message}}</b>             {% endif %}                      <form id="form" method="post" action="">{% csrf_token %}             <table>{{form}}</table>             <div class="col-lg-9 col-lg-offset-2">                                      <button type="submit" class="btn btn-primary">submit</button>                 </div>           </form>                   </div>    

here url:

url(r'^login', 'users.views.login', name='login'), 

and here view:

from django.shortcuts import render deck1.models import card django.template import requestcontext django.shortcuts import render_to_response django.http import httpresponseredirect, httpresponse django.contrib.auth.forms import usercreationform django.contrib.auth.forms import authenticationform django.contrib.auth import login, authenticate, logout django.contrib.auth.decorators import login_required users.forms import registerform  def login(request):     message = none     if request.method=='post':         form = authenticationform(request.post)         if form.is_valid():                      username = request.post['username']             password = request.post['password']             user = authenticate(username=username, password=password)             if user not none:                 if user.is_active:                     login(request, user)                     message = "i'm in"                 else:                     message = "non active"             else:                 message = "user or password invalid"     else:         form = authenticationform()                      return  render_to_response('login.html',{'form':form, 'message':message}, context_instance=requestcontext(request)) 

your form's action attribute empty.

should be: action="{% url 'login' %}".


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -