登录时加入“@”页面无反应
来源:6-3 用户登录-2
逍遥生4
2018-04-30
在登录页面只要存在符号@,点击登录按钮会由“快速登录”变为“登录”,且点击无反应
# -*- coding=utf-8 -*- from django.shortcuts import render from django.contrib.auth import authenticate,login from django.contrib.auth.backends import ModelBackend from django.db.models import Q from django.views.generic.base import View from django.contrib.auth.hashers import make_password from.models import UserProfile # Create your views here. class CustomBackend(ModelBackend): def authenticate(self, username=None, password=None, **kwargs): try: user = UserProfile.objects.get(Q(username=username)|Q(email=username)) if user.check_password(password): return user except Exception as e: return None def User_login(request): if request.method == "POST": user_name = request.POST.get("username", "") pass_word = request.POST.get("password", "") user = authenticate(username=user_name,password=pass_word) if user is not None: login(request,user) return render(request,"index.html") else: return render(request,"login.html",{}) elif request.method == "GET": return render(request,"login.html",{})
写回答
2回答
-
逍遥生4
提问者
2018-05-02
自己排查了好久,终于发现了问题。问题出在源码的js文件里,源码载入的第三个js,validateDialog.js,它会用js重写登录页面的登录按钮,导致form表单的submit被覆盖无法触发。解决办法就是删掉登录页面的validateDialog.js
112018-05-02 -
Noah_________
2018-05-02
# 在settings.py里面重载AUTHENTICATION_BACKENDS了吗?
AUTHENTICATION_BACKENDS = ( 'users.views.CustomBackend', )
点击登录按钮会由“快速登录”变为“登录”是什么意思?
032018-05-03
相似问题