首页 > 代码库 > Django1-10-5管理界面中文设置

Django1-10-5管理界面中文设置

先确定一下版本是否更高,低版本设置(settings.py文件):

LANGUAGE_CODE = ‘zh-CN‘

TIME_ZONE = ‘Asia/Shanghai‘

但是新版本就会提示不识别zh-CN,网上查了一下会让你添加 ‘django.middleware.locale.LocaleMiddleware‘到settings.py文件中的MIDDLEWARE中,并且还要放在‘django.contrib.sessions.middleware.SessionMiddleware‘之后,

然后语言类型设置:

LANGUAGE_CODE = ‘zh-Hans‘

TIME_ZONE = ‘Asia/Shanghai‘

登陆发现没错,但是显示的还是英文,

然后我把那句注释掉,如下:

MIDDLEWARE = [
‘django.middleware.security.SecurityMiddleware‘,
‘django.contrib.sessions.middleware.SessionMiddleware‘,
#‘django.middleware.locale.LocaleMiddleware‘,
‘django.middleware.common.CommonMiddleware‘,
‘django.middleware.csrf.CsrfViewMiddleware‘,
‘django.contrib.auth.middleware.AuthenticationMiddleware‘,
‘django.contrib.messages.middleware.MessageMiddleware‘,
‘django.middleware.clickjacking.XFrameOptionsMiddleware‘,

]


刷新就可以显示中文了!(具体实现望高手评论)
MIDDLEWARE = [
‘django.middleware.security.SecurityMiddleware‘,
‘django.contrib.sessions.middleware.SessionMiddleware‘,
#‘django.middleware.locale.LocaleMiddleware‘,
‘django.middleware.common.CommonMiddleware‘,
‘django.middleware.csrf.CsrfViewMiddleware‘,
‘django.contrib.auth.middleware.AuthenticationMiddleware‘,
‘django.contrib.messages.middleware.MessageMiddleware‘,
‘django.middleware.clickjacking.XFrameOptionsMiddleware‘,

]

Django1-10-5管理界面中文设置