def signin(request): if request.method == 'GET': return render(request, 'front_signin.html') else: form = SigninForm(request.POST) print form.is_valid() if form.is_valid(): email = form.cleaned_data.get('email') password = form.cleaned_data.get('password') user = login(request, email, password) if user: remember = form.cleaned_data.get('remember') if remember: request.session.set_expiry(None) else: request.session.set_expiry(0) nexturl = request.GET.get('next') print nexturl if nexturl: return redirect(nexturl) else: return redirect(reverse('front_index')) else: return render(request, 'front_signin.html', {'error': u'用户名和密码错误'}) else: return render(request, 'front_signin.html', {'error': form.get_error()})
def signin(request): if request.method == "POST": form = SigninForm(request.POST) if form.is_valid(): form.save() newUser=authenticate(username=form.cleaned_data["username"], password=form.cleaned_data["password1"]) authlogin(request, newUser) return HttpResponseRedirect("/") else : form = SigninForm() data={ "form":form, } return render(request,"blog/mobile/registration/signin.html",data)
def signin(request): context = {} context['form'] = SigninForm() if request.method == 'POST': form = SigninForm(request.POST) context['form'] == form if form.is_valid(): username = form.cleaned_data['username'] password = form.cleaned_data['password'] try: auth_user = authenticate(username=username, password=password) login(request, auth_user) return redirect('/countrylist/') except Exception, e: return HttpResponse( 'Wrong USERNAME or PASSWORD! Please <a href="/signin/">Try Again </a>' )