如何让用户在Django中更改自己的密码? [英] How to allow users to change their own passwords in Django?

查看:119
本文介绍了如何让用户在Django中更改自己的密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案


任何一个人都可以指定代码,用户可以在Django中更改自己的密码? p> Django自带一个用户
认证系统。它处理用户
帐户,组,权限和
基于cookie的用户会话。这个
文件解释了事情如何运作。


如何更改Django密码



请参阅更改密码部分


  1. 导航到您的项目,其中 manage.py p>


  2. $ python manage.py shell


  3. <

    键入以下脚本:




 
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

  1. Navigation to your project where manage.py file lies

  2. $ python manage.py shell

  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆