中文+django1.9+python3.5一些注意点

1、模板html文件里一定要加

<!DOCTYPE html>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<html lang="zh">

这几句,否则就会报python35 django utf-8' codec can't decode byte 0xb2 in position 93: invalid错误

2、由于mysqldb这个模块不太好安装,所以用pymysql这个轻量级库来代替,在settings的__init__.py里写这几句

import pymysql
pymysql.install_as_MySQLdb()

或者直接写入setting文件

3、在settings文件的MIDDLEWARE_CLASSES里把django.middleware.security.SecurityMiddleware这行配置注释掉,django1.9以上版本都不成功,不知道是什么原因,至今未找到解决方法

先写这几点,后续如有再补充

原文地址:https://www.cnblogs.com/slqt/p/5315504.html