我的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