在应用程序之前无法初始化翻译基础结构

时间:2016-02-02 15:49:03

标签: django

我正在关注Django Doc,但是当我这样做时,我收到以下错误消息。

ODBC Data Source Administrator

Settings.py

"The translation infrastructure cannot be initialized before the "
django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

我理解这是因为在加载必要的lib之前调用了转换,但是如果文档以这种方式说明,我怎么能改变呢?

WSGI.py

LANGUAGE_CODE = 'en'

LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale/'),
)

USE_I18N = True

USE_L10N = True

USE_TZ = True

TIME_ZONE = 'Europe/Copenhagen'

from django.utils.translation import ugettext as _

LANGUAGES = [
  ('da', _('Danish')),
  ('en', _('English')),
]

0 个答案:

没有答案