python登录代码的实现
首页 / 频道 / 显示主题:python登录代码的实现

python登录代码的实现


时间:2014年11月24日 08:01:32点击:1287类别:解决方案

 (测试SyntaxHighlighter插件)python登录代码的实现:

def alogin(request):  
    errors= []  
    account=None  
    password=None  
    if request.method == 'POST' :  
        request.session['login_from'] = request.META.get('HTTP_REFERER', '/') 
        account = request.POST['account']  
        password= request.POST['password']  
        if account is not None and password is not None :
            user = auth.authenticate(username=account,password=password)
            if user:
                    auth.login(request,user)
                    request.session['is_logined']=True
                    request.session['nick']=account
                    users=User.objects.get_by_natural_key(username=account)
                    request.session['uid']=users.id
                    request.session['email']=users.email
                    return HttpResponseRedirect(request.session['login_from'])
            else:
                errors=''
         return HttpResponse(errors)


详细代码如下:

楼主kkds2014

喜欢:(1287)  回复:(1)

0

以下为回复内容


读后有收获可以添加作者微信共同交流
打赏作者

1#楼的ヾ(。`Д´。)2014年12月07日 14:53:50回复道:

坚决消灭零回复!

我们必胜!

yeah~!




也回复一个  举报