Python Django添加superuser 拂晓风起

from django.contrib.auth.models import User
user=User.objects.create_superuser('name','emailname@demon.com','password')

第一个为用户名,第二个是邮箱,第三是密码

用这个方法可能会出错,系统环境变量中添加DJANGO_SETTINGS_MODULE变量,将其值设置为mysite.settings(mysite为工作目录中的project名称)

添加PYTHONPATH:D:\\python27;F:\workforce\python
(F:\workforce\python为python project的工作目录)
再运行,可能还有错,我用Django+Mysql,我没搞明白为什么还是错,但用户是建立成功了,懒得理它了。
另外:

官方:http://docs.djangoproject.com/en/dev/topics/auth/#topics-auth-creating-superusers

manage.py createsuperuser --username=joe --email=joe@example.com

You will be prompted for a password. After you enter one, the user will be
created immediately.
kenkofox@qq.com https://github.com/kenkozheng 欢迎投简历给我,一线大厂工作机会
原文地址:https://www.cnblogs.com/kenkofox/p/1970372.html