Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django makemessages不';在区域设置路径中看不到区域设置_Python_Linux_Django_Django I18n - Fatal编程技术网

Python Django makemessages不';在区域设置路径中看不到区域设置

Python Django makemessages不';在区域设置路径中看不到区域设置,python,linux,django,django-i18n,Python,Linux,Django,Django I18n,我的设置中有自定义区域设置路径 PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '..')) LOCALE_PATHS = ( os.path.join(PROJECT_ROOT,'templates','v1','locale'), ) 但当我试图创建.po文件时,我得到了一个错误: $ python manage.py makemessages --locale=ru CommandEr

我的设置中有自定义区域设置路径

PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
LOCALE_PATHS = (
    os.path.join(PROJECT_ROOT,'templates','v1','locale'),
)
但当我试图创建.po文件时,我得到了一个错误:

$ python manage.py makemessages --locale=ru
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.
为什么django不想使用LOCALE\u路径

绝对路径为: PROJECT_ROOT='/home/creotiv/ENVS/PROJECT_env/PROJECT/PROJECT' LOCALE_path=('/home/creotiv/ENVS/project_env/project/project/templates/v1/LOCALE')


另外,我在主应用程序中添加了翻译,django也没有看到。也许你必须进入应用程序或项目目录。试试这个:

$ ls  # should return also the manage.py
$ cd myproject
$ ls  # should return also the settings.py
$ python ../manage.py makemessages --locale=ru
第一件事优先;您需要为python提供正确的
manage.py
路径

$ python /path/to/the/manage.py makemessages --locale=ru
或者转到包含的目录
manage.py
。然后运行你在问题中编写的命令

$ python manage.py makemessages --locale=ru
其次;您是否在项目主页下创建了
/templates/v1/locale
目录

根据错误,您可以检查
/templates/v1/locale'
文件夹是否存在

还有,;您可能需要将
语言
设置附加到项目
设置.py
文件中:

LANGUAGES = (
    ('ru', _('Russian')),
    ('en', _('English')),  # (Optional)
)
附件:


如果您在虚拟环境下开发,请不要忘记首先启用虚拟环境

刚刚更新到django 1.7,问题已经解决。

您通常使用django admin makemessages。CommandError有时会由此生成。用适当的命令按命令去做。此外,您还可以选择是否可以添加“项目根目录”、“manage.py”、“settings.py”和“locale”文件夹的绝对路径?@SencerH。添加了奇怪的路径。更新前您使用了哪个版本?我想是1.6.4(我不记得了)