安装django-cms报错,ImproperlyConfigured: LANGUAGE_CODE "en-us" must have a matching entry in LANGUAG解决办法

ImproperlyConfigured: LANGUAGE_CODE "en-us" must have a matching entry in LANGUAGES

[17/Apr/2014 17:48:10] "GET /zh-cn/ HTTP/1.1" 500 59


这个issue在github上提交过,传送门 https://github.com/divio/django-cms/issues/2179




回答是这样的:

If your LANGUAGE_CODE is 'en-us' and in your LANGUAGES you have: 'en' and 'de' then django actually supports 3 languages: 'en-us', 'en' and 'de'. The problem is that 'en-us' is not the same as 'en' and it is possible that request.LANGUAGE_CODE becomes 'en-us' if you don't have the language accept headers set. We have 2 possible solutions: Either we add LANGUAGE_CODE to CMS_LANGUAGES as well... and then you can create pages in 'en-us' and 'en' or we enforce that LANGUAGE_CODE is in LANGUAGES. To be honest i think the django docs in this regard should be updated as most people will not understand what is going on in the back and only encounter 500 after they go live and they receive a request without a accept language header and have a new language to deal with for the first time.

PS. over the years i had soooo many bug reports because of this behavior that i finally decided to enforce the LANGUAGE_CODE in LANGUAGES as it makes absolutely sense in a i18n environment.


有两种解决方案,我用的后一种:在LANGUAGES里把 ('en', gettext_noop('English')) 改成 ('en-us', gettext_noop('English')),


LANGUAGES = (
    ('en-us', gettext_noop('English')),
    ('zh-cn', gettext_noop('Simplified Chinese')),
    ('zh-tw', gettext_noop('Traditional Chinese')),
)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值