其他分享
首页 > 其他分享> > Django-账户用户忘记密码

Django-账户用户忘记密码

作者:互联网

  1. 方法1:Terminal命令
    •  python manage.py changepassword admin

       Password: PY666666

       Password (again): PY666666

  1. 方法2:shell命令方式对密码进行修改(默认user)
    • from django.contrib.auth.models import User
      user = User.objects.get(username='admin')
      user.set_password('PY666666')
      user.save()
  2. 方法3:shell命令方式对密码进行修改(扩展后的user)
    • from django.contrib.auth.models import User
      from django.contrib.auth import get_user_model
      User=get_user_model()
      user=User.objects.get(username='admin')
      user.set_password('PY666666')
      user.save()

       

标签:get,PY666666,Django,密码,User,contrib,import,忘记,user
来源: https://www.cnblogs.com/beichengshiqiao/p/16130194.html