简体   繁体   English

当django放在鸡蛋里时,如何运行django-admin.py?

[英]How to run django-admin.py, when django is in an egg?

I have inherited a project, which was deployed with buildout and is running fine. 我继承了一个项目,该项目已通过构建部署并运行良好。 I've made some changes in the translation .po file, but to compile to .mo file I need to run 我已经对翻译.po文件进行了一些更改,但是要编译成.mo文件,我需要运行

django-admin.py compilemessages

How can I do this, when the only place I find django-admin.py is in an egg? 当我唯一找到django-admin.py的地方是鸡蛋时,该怎么办? The project is not using virtualenv. 该项目未使用virtualenv。

If you are not using virtualenv then everything should be on your PYTHONPATH . 如果您没有使用virtualenv那么所有内容都应该在PYTHONPATH With that in mind look at https://github.com/django/django/blob/master/django/bin/django-admin.py : 考虑到这一点, 查看https://github.com/django/django/blob/master/django/bin/django-admin.py

#!/usr/bin/env python
from django.core import management

if __name__ == "__main__":
    management.execute_from_command_line()

Not the big deal to make your own django-admin.py , isn't it? 制作自己的django-admin.py ,不是吗? And that should do the trick. 这应该可以解决问题。 But don't forget to set DJANGO_SETTINGS_MODULE env variable. 但是不要忘记设置DJANGO_SETTINGS_MODULE变量。

Apparently, there was a django file, which set all of the eggs to be in sys.path, and then passed commands to django. 显然,有一个django文件,该文件将所有鸡蛋设置在sys.path中,然后将命令传递给django。 I don't know if that is standard in buildout, though. 不过,我不知道这是否是标准配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM