Django 设置 LANGUAGE_CODE = 'zh-Hans' 报错

Django框架开发项目时,在settings.py中设置 中文 语言时报错:

LANGUAGE_CODE = 'zh-Hans'

报错:ERRORS:
?: (translation.E004) You have provided a value for the LANGUAGE_CODE setting that is not in the LANGUAGES setting.

处理办法,头部引入:

from django.utils.translation import gettext_lazy as _

在LANGUAGE_CODE = 'zh-Hans' 上方添加:

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

发布了39 篇原创文章 · 获赞 10 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/chiaotien/article/details/103848040