运维开发笔记整理-创建django用户
运维开发笔记整理-创建django用户
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.创建普通用户
C:\Users\yinzhengjie\softwares\PycharmProject\DevOps>python manage.py shell Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> >>> >>> from django.contrib.auth.models import User >>> >>> user = User.objects.create_user("yinzhengjie", "yinzhengjie@yinzhengjie.org.cn", "123") >>>
二.创建管理员
C:\Users\yinzhengjie\softwares\PycharmProject\DevOps>python manage.py createsuperuser Username: admin Email address: admin@yinzhengjie.org.cn Password: Password (again): Superuser created successfully. C:\Users\yinzhengjie\softwares\PycharmProject\DevOps> C:\Users\yinzhengjie\softwares\PycharmProject\DevOps>
三.修改用户名的密码
1>.在数据库中查看刚刚创建的2个用户信息
mysql> select * from auth_user\G
2>.进入Django自带的shell环境修改密码
C:\Users\yinzhengjie\softwares\PycharmProject\DevOps>python manage.py shell Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.contrib.auth.models import User >>> >>> >>> u = User.objects.get(username='yinzhengjie') >>> >>> u.set_password('7474741') >>> >>> u.save() >>> >>>
本文来自博客园,作者:尹正杰,转载请注明原文链接:https://www.cnblogs.com/yinzhengjie/p/10246850.html,个人微信: "JasonYin2020"(添加时请备注来源及意图备注,有偿付费)
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。