spidernyp

我的django的版是3.0.2 

按照网上大牛的办法设置了还是不行,先记录在此

#开头定义
from django.utils.translation import gettext_lazy as _
#LANGUAGES_CODE前添加 
LANGUAGES = [
    (\'zh-Hans\', _(\'Chinese\')),
]

LANGUAGE_CODE = \'zh-Hans\'

仍然报错

?: (translation.E001) You have provided an invalid value for the LANGUAGE_CODE setting: \'zh_Hans\'.
?: (translation.E004) You have provided a value for the LANGUAGE_CODE setting that is not in the LANGUAGES setting.

 

2020/3/8 找到另一篇文章,顺利解决这个问题

LANGUAGES = [
   (\'zh-Hans\', _(\'Chinese\')),
]


LANGUAGE_CODE = \'zh-Hans\'

TIME_ZONE = \'Asia/Shanghai\'

USE_I18N = True

USE_L10N = True

USE_TZ = False

  并在头部添加

from django.utils.translation import gettext_lazy as _

和以前的处理办法相比,其实是少了

use_TZ = False ,之前是true

分类:

技术点:

相关文章: