【Python】Django auth 修改密码如何实现?
2024-10-22 02:41:54
使用示例
1.创建用户
>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword')
# At this point, user is a User object that has already been saved
# to the database. You can continue to change its attributes
# if you want to change other fields.
>>> user.is_staff = True
>>> user.save()
2.修改密码
>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username__exact='john')
>>> u.set_password('new password')
>>> u.save()
创建超级管理员
manage.py createsuperuser --username=joe --email=joe@example.com
前端效果:
参考资料:
Django中的Users权限系统:http://blog.chinaunix.net/uid-25525723-id-331051.html
自己做的修改密码页面,自动弹出不需要的东西 :http://mozilla.com.cn/thread-329027-1-1.html
最新文章
- HAProxy的日志配置以及ACL规则实现负载均衡
- [tem]树状数组
- Form 详细属性--2016年12月4日
- python 自带的ide 不能保存文件
- mybatis - resultMap
- Atitit 电子商务订单号码算法(java c# php js 微信
- 百度地图的简单使用 ——html js
- 如何设置启动页 LaunchImage
- Oracle GoldenGate 12c实时捕获SQL Server数据
- segment fault
- 51单片机连接24C02-C语言测试代码
- Springmvc整合mybatis
- 微信开放平台 获取 component_verify_ticket
- .NEL IL实现对象深拷贝
- java中volatile的简单理解
- Log4j使用笔记:每天生成一个日志文件、按日志大小生成文件
- docker基础学习(一)
- SpringSecurity认证处理流程
- PHP http_build_query()方法
- Search for a Range leetcode java
热门文章
- ref:ThinkPHP Builder.php SQL注入漏洞(<;= 3.2.3)
- Java常用工具类之MD5加密
- Centos7 安装单节点Torque PBS
- shell中的cat和文件分界符(<;<;EOF) (转)
- 【BZOJ 3106】 3106: [cqoi2013]棋盘游戏 (对抗搜索)
- 【BZOJ 2728】 2728: [HNOI2012]与非 (线性基?)
- [BOI2004]Sequence
- 2018 计算之道初赛第二场 阿里巴巴的手机代理商(困难)(反向可持久化Trie)
- 修改选择排序 Exercise07_20
- bzoj 1211: [HNOI2004]树的计数 -- purfer序列