首页 > 技术文章 > pycharm运行Django项目,提示UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6

sitongyan 2019-04-26 11:07 原文

确认pycharm编码都是utf-8的情况下,需要修改项目中settings.py

'DIRS': [ ],默认是空,将路径加入即可解决。

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR,  'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

 

推荐阅读