没有找到域'django'的翻译文件

时间:2015-11-19 11:30:10

标签: python django

环境:

  • python 2.7.10
  • django 1.8.6(从site-package文件夹复制)

我将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 packege。

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

我想我得到了解决方案,我的.gitignore文件忽略了.mo文件,我添加了它,现在一切都还好

如果您使用的是git,请检查您的.gitignore文件并发表评论*.mo

添加缺少的.mo文件,事情会很好