首页新闻找找看学习计划

django auth.authenticate的 一个问题

0
悬赏园豆:50 [已解决问题] 解决于 2019-12-27 17:42

我在django自带的auth_user 表中添加了一条用户信息

User.objects.create_user
 
auth.authenticate验证这条信息的时候报错
ValueError: not enough values to unpack (expected 4, got 2)
 
是django哈希加密那一块的东西 有没有懂得大佬帮忙看一下
 
错误原图
Traceback (most recent call last):
  File "C:\Users\hjz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Users\hjz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Users\hjz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\hjz\Desktop\sweeper\sweeper\sweepintell\login\views.py", line 47, in login
    user = auth.authenticate(username=username, password=password ,usernum="",useraddperson="")
  File "C:\Users\hjz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\__init__.py", line 73, in authenticate
    user = backend.authenticate(request, **credentials)
  File "C:\Users\hjz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\backends.py", line 22, in authenticate
    if user.check_password(password) and self.user_can_authenticate(user):
  File "C:\Users\hjz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\base_user.py", line 111, in check_password
    return check_password(raw_password, self.password, setter)
  File "C:\Users\hjz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\hashers.py", line 50, in check_password
    must_update = hasher_changed or preferred.must_update(encoded)
  File "C:\Users\hjz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\hashers.py", line 267, in must_update
    algorithm, iterations, salt, hash = encoded.split('$', 3)
ValueError: not enough values to unpack (expected 4, got 2)

 

问题补充:

我在models里重构了auth_user表,我测试不重写user表的时候没什么问题

自说自话唉的主页 自说自话唉 | 初学一级 | 园豆:193
提问于:2019-12-27 11:33
< >
分享
最佳答案
0

重构user表时候models里定义字段username和password,冲突,注释后重新迁移数据库,问题解决

自说自话唉 | 初学一级 |园豆:193 | 2019-12-27 14:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册