Django 管理员丢失密码恢复

发布于 2024-09-28 23:22:00 字数 145 浏览 0 评论 0原文

我的开发数据库中有一些数据(尚未导出到固定装置),所以我不想运行syncdb。

但是,我丢失了我的演示 django 网站的管理部分的密码(我有一段时间没有使用它)

密码是否存储在配置/设置等中的某个位置?

如何恢复管理员密码?

I have some data in my dev database (not yest exported to fixtures), so I dont want to run syncdb.

However, I have lost my pwd for the admin section of my demo django website (I have not worked on it for a little while)

Is the password stored somewhere in the config/settings etc?

How can I recover the admin pwd?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

另类 2024-10-05 23:22:00

如果您安装了 Django 1.2,则只需调用 ./manage.py changepassword 即可。

如果您的 Django 版本较旧,您可以在 Django 的交互式 shell 中更改密码:

>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username='<username>')
>>> u.set_password('<password>')
>>> u.save()

If you have Django 1.2 installed, you can simply invoke ./manage.py changepassword <username>.

If your version of Django is older, you could change the password in Django's interactive shell:

>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username='<username>')
>>> u.set_password('<password>')
>>> u.save()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文