Django,使用绝对路径执行时自定义管理命令出错
我有一个名为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到原因了,看来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