Django修改用户名密码的方法

2021-03-18 11:22:16 浏览数 (1)

方法一

代码语言:javascript复制
python manage.py shell
from django.contrib.auth.models import User
user=User.objects.get(username='XXX')
user.set_password('new_password')
user.save()

方法二

代码语言:javascript复制
D:PyCharm-ProjectdjangoProjectYz_admin>python manage.py changepassword yz
Changing password for user 'yz'
Password:
Password (again):
Password changed successfully for user 'yz'

0 人点赞