问题?
django2.0下使用authenticate()验证默认 关联is_active字段。
当is_active=0时,user = authenticate(username=username, password=password) 会一直返回None。
解决方法
在settings.py文件中加入下列配置
# 取消authenticate关联is_active
AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.AllowAllUsersModelBackend']