Django,使用绝对路径执行时自定义管理命令出错

发布于 2024-09-18 20:52:51 字数 424 浏览 3 评论 0原文

我有一个名为 temp.py 的自定义管理命令,位于 /home/user/project/monitor/management/commands 下。如果我将目录更改为 /home/user/ 并执行:

user@localhost:~/project$ ./manage.py temperature

它运行正常,并且在可用命令中列出。但是,如果我尝试使用绝对路径运行它:

user@localhost:/$ /home/user/project/manage.py temperature

它说该命令不存在,它也不会显示在可用命令中。我在 ubuntu 10.04 中有 django 1.2.1 和 python 2.6.5。这可能是 django 的问题吗?是python版本吗?提前致谢

I have a custom admin command named temperature.py which is under /home/user/project/monitor/management/commands. If I change directory to /home/user/ and execute:

user@localhost:~/project$ ./manage.py temperature

It runs ok, and its listed in the available commands. But if I try running it with the absolute path:

user@localhost:/$ /home/user/project/manage.py temperature

It says the command does not exist, it does not show up in the available commands either. I have django 1.2.1 with python 2.6.5 in ubuntu 10.04. Could this be a problem with django? is it the python version? Thanks in advance

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

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

发布评论

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

评论(1

无人接听 2024-09-25 20:52:51

找到原因了,看来django是在主目录下寻找设置,如果找不到就使用默认值。您可以更改Python路径或在manage.py文件中使用 this

Found the reason, it seems that django is looking for the settings under the main directory, if it fails to find one, it will use the defaults. You can change your python path or use this in your manage.py file

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