【Django】Admin密码问题
时间:2015-07-23 12:07:41 作者:vaster 标签: admin django 分类: Django 编程
之前用Django做了一个资源查询平台,近期把备份的代码和数据库重新部署上后,发现Admin的密码给忘记了,遇到这种情况如何处理呢?
方法一:再创建一个超级用户
# python manage.py createsuperuserUsername (leave blank to use 'root'): root_testEmail address: root_test@itopers.comPassword:Password (again):Superuser created successfully.
方法二:给原来的超级用户重置密码
确定超级用户的名字,进入数据库
mysql> select username,is_superuser from auth_user where is_superuser=1;+-----------+--------------+| username | is_superuser |+-----------+--------------+| vaster | 1 |+-----------+--------------+7 rows in set (0.00 sec)7 rows in set (0.00 sec)
为vaster用户重置密码
# python manage.py shellPython 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2Type "help", "copyright", "credits" or "license" for more information.(InteractiveConsole)>>> from django.contrib.auth.models import User>>>user = User.objects.get(username='vaster')>>>user.set_password('new_password')>>>user.save()>>>user.save()
修改完毕之后,又可以开心地玩耍啦!~