如何让用户在Django中更改自己的密码? [英] How to allow users to change their own passwords in Django?
问题描述
任何一个人都可以指定代码,用户可以在Django中更改自己的密码? p> Django自带一个用户
认证系统。它处理用户
帐户,组,权限和
基于cookie的用户会话。这个
文件解释了事情如何运作。
请参阅更改密码部分
-
导航到您的项目,其中
manage.py
p> -
$ python manage.py shell
<
键入以下脚本:
from django.contrib.auth.models import用户
u = User.objects.get(username__exact ='john')
u.set_password('新密码')
u.save()
您还可以使用简单的 manage.py
命令:
manage.py changepassword * username *
只需输入新密码两次。
来自 更改密码 部分。
如果您的 INSTALLED_APPS
中有 django.contrib.admin
,则可以访问:示例.com / path-to-admin / password_change /
其中将有一个表单来确认您的旧密码并输入新密码两次。
Can any one point me to code where users can change their own passwords in Django?
Django comes with a user authentication system. It handles user accounts, groups, permissions and cookie-based user sessions. This document explains how things work.
How to change Django passwords
See the Changing passwords section
Navigation to your project where
manage.py
file lies$ python manage.py shell
type below scripts :
from django.contrib.auth.models import User u = User.objects.get(username__exact='john') u.set_password('new password') u.save()
You can also use the simple manage.py
command:
manage.py changepassword *username*
Just enter the new password twice.
from the Changing passwords section in the docs.
If you have the django.contrib.admin
in your INSTALLED_APPS
, you can visit: example.com/path-to-admin/password_change/
which will have a form to confirm your old password and enter the new password twice.
这篇关于如何让用户在Django中更改自己的密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!