gpt4 book ai didi

python - 找不到域 'django' 的翻译文件

转载 作者:行者123 更新时间:2023-11-28 19:15:40 25 4
gpt4 key购买 nike

环境:

  • python 2.7.10
  • django 1.8.6(从站点包文件夹复制)

我将 django 分发复制到我的项目文件夹中。

认为它会很好用

它在我的一台机器上运行完美,但在另一台机器上抛出下面的错误

Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "cmdb_lib/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "cmdb_lib/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "cmdb_lib/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "cmdb_lib/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "cmdb_lib/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "cmdb_lib/django/core/management/base.py", line 458, in execute
translation.activate(saved_locale)
File "cmdb_lib/django/utils/translation/__init__.py", line 146, in activate
return _trans.activate(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 222, in activate
_active.value = translation(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 206, in translation
_translations[language] = DjangoTranslation(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 115, in __init__
self._init_translation_catalog()
File "cmdb_lib/django/utils/translation/trans_real.py", line 153, in _init_translation_catalog
translation = self._new_gnu_trans(localedir, use_null_fallback)
File "cmdb_lib/django/utils/translation/trans_real.py", line 136, in _new_gnu_trans
fallback=use_null_fallback)
File "/usr/local/lib/python2.7/gettext.py", line 472, in translation
raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: u'django'

但在我的 settings.py 中,我将 LANGUAGE_CODE = 'en-us' 设置为默认值!

这怎么会抛出错误?

我尝试pip install django,问题解决了,但我仍然想在我的项目中包含django包。

我怎样才能做到这一点?

最佳答案

我想我找到了解决方案,我的 .gitignore 文件忽略了 .mo 文件,我添加了它,现在一切正常了

如果您使用的是 git,请检查您的 .gitignore 文件并注释*.mo

添加缺少的 .mo 文件,一切都会好起来的

关于python - 找不到域 'django' 的翻译文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33802686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com