django:无法导入设置,无法登录管理员,无法更改管理员密码

发布于 2024-10-10 00:14:42 字数 1109 浏览 0 评论 0原文

看来我完全迷失在这里了。昨天我注意到我无法登录管理面板(不经常使用它,所以距离上次登录已经有几周了)。我以为我可能更改了管理员密码,但现在我不记得了(尽管我对此表示怀疑)。

我尝试了 django-admin.py changepassword (使用 django 1.2.1),但它说“changepassword”是未知命令(我在我的 settings.py 中有所有必要的导入。管理界面过去工作正常)。

然后我给了 django-admin.py 验证。然后地狱就开始了。 django-admin.py 验证给了我这个错误:错误:无法导入设置,因为环境变量 DJANGO_SETTINGS_MODULE 未定义。

然后我给出了一组 DJANGO_SETTINGS_MODULE=myproject.settings

,然后再次进行 django-admin.py 验证

这就是我现在得到的: 错误:无法导入设置“myproject.settings”(它在 sys.path 上吗?它有语法吗错误?):没有名为 myproject.settings 的模块

,现在我迷路了。我尝试了 django console 和 sys.path.append('c:\workspace') 或 sys.append('c:\workspace\myproject') 但仍然遇到相同的错误。

我使用 Windows 7,我的项目目录是 c:\workspace。我不使用 PYTHONPATH 变量(尽管我尝试将其临时设置为 C:\workspace 但仍然遇到相同的错误)。我不使用 Apache,只使用 django 开发服务器。

我做错了什么?我的网页运行良好。我认为我无法以管理员身份登录的事实与之前的导入错误有关,不是吗?

PS:我也尝试过:http://coderseye。 com/2007/howto-reset-the-admin-password-in-django.html 但由于某种原因我仍然无法更改管理员密码。虽然我可以创建另一个管理员用户(我无法登录)。

-编辑-我忘了提及我使用 postgresql。

It seems that I am completely lost here. Yesterday I noticed that I cannot login to the admin panel (don't use it much, so it's been some weeks since last login). I thought that I might have changed the admin password and now I can't remember it (though I doubt it).

I tried django-admin.py changepassword (using django 1.2.1) but it said that 'changepassword' is unknown command (I have all the necessary imports in my settings.py. Admin interface used to work ok).

Then I gave a django-admin.py validate. Then the hell begun. django-admin.py validate gave me this error: Error: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

I then gave a set DJANGO_SETTINGS_MODULE=myproject.settings

and then again a django-admin.py validate

This is what I get now: Error: Could not import settings 'myproject.settings' (Is it on sys.path? Does it have syntax errors?): No module named myproject.settings

and now I am lost. I tried django console and sys.path.append('c:\workspace') or sys.append('c:\workspace\myproject') but still get the same errors.

I use windows 7 and my project dir is c:\workspace. I don't use a PYTHONPATH variable (although I tried setting it temporarily to C:\workspace but I still get the same error). I don't use Apache, just the django development server.

What am I doing wrong? My web page works fine. I think that the fact that I can't login as admin is related to the previous import error, no?

PS: I also tried this: http://coderseye.com/2007/howto-reset-the-admin-password-in-django.html but still I couldn't change admin password for some reason. Although I could create another admin user (with which I couldn't login).

-EDIT- I forgot to mention that I use postgresql.

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

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

发布评论

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

评论(1

迎风吟唱 2024-10-17 00:14:43

django-admin.py 没有 changepassword 选项;

python manage.py 确实

django-admin.py doesnot have changepassword option;

python manage.py does

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文