因此,我使用 Ant 构建脚本通过 manage.py
运行一些 Django 命令,我开始看到错误,但即使从 python 运行时也是如此;
C:\Users\markw\work\proj\src>python manage.py makemessages --all
--ignore=unittests\* --no-wrap
CommandError: This script should be run from the Django Git tree or your project
or app tree. If you did indeed run it from the Git checkout or your project or
application, maybe you are just missing the conf/locale (in the django tree) or
locale (for project and application) directory? It is not created automatically,
you have to create it by hand if you want to enable i18n for your project or
application.
我的工作副本中唯一的变化与 ANT 相关,更让我困惑的是,以下 ANT 任务正确完成(以及只是从 python 运行它);
<!-- Compile the translations -->
<target name="compile.trans" depends="init.properties">
<exec executable="${deps.python}"
dir="src"
failonerror="true">
<arg value="manage.py"/>
<arg value="compilemessages"/>
</exec>
</target>
makemessages
有什么特别之处吗?我试过从 src
运行它,比如 compilemessages
就在一天前,还有 mysite
和 django
有一个包含 .po
文件的 locale
文件夹。
目录结构;
- proj
-- django
-- conf
-- locale
-- mysite
-- locale
manage.py
设置:
LOCALE_PATHS = (
os.path.join(settings_central.BASE_PATH, 'templates', 'locale',),
os.path.join(settings_central.BASE_PATH, 'mysite', 'locale',),
os.path.join(settings_central.BASE_PATH, 'django', 'locale',),
)
最佳答案
您的项目布局略有不正确。您的项目 locale
目录应该是 proj/locale
而不是 proj/mysite/locale
,真的。
关于python - makemessages "should be run from the Django Git tree or your project or app tree"上的 Django 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21882785/