一些Django错误问题解决方法总结
错误: No module named 模块名称
找不到模块,需要将模块添加到Python的搜索目录中。
方法一、在运行时添加参数--pythonpath="路径"
方法二、将路径添加到path中。在settings.py中增加sys.path.insert(0,"path")
方法三、安装模块到python的dist-packages文件夹中
错误:Module "django.core.context_processors" does not define a "auth" callable request processor
TEMPLATE_CONTEXT_PROCESSORS 得值原来版本的django.core.context_processors.auth 修改为django.contrib.auth.context_processors.auth
错误:Error importing template source loader django.template.loaders.filesystem.load_template_source: "'module' object has no attribute 'load_template_source'"
将TEMPLATE_LOADERS的'django.template.loaders.filesystem.load_template_source'修改为'django.template.loaders.filesystem.Loader'
另一个同样去掉load_template_source
错误:Incorrect string value: '\xE5\x95\x8A\xE7\xAC\xAC...' for column 'name' at row 1
将数据库编码修改为utf8,mysql的修改方式为:
[mysqld]
character-set-server=utf8
[mysql]
default-character-set=utf8
数据表修改:alter database db_name character set utf8 collate utf8_general_ci;
错误:提示找不到模板文件
查看template路径是否正确,路径下是否有相应的文件
推荐阅读:
Ubuntu Server 12.04 安装Nginx+uWSGI+Django环境 http://www.linuxidc.com/Linux/2012-05/60639.htm
Django实战教程 http://www.linuxidc.com/Linux/2013-09/90277.htm
Django Python MySQL Linux 开发环境搭建 http://www.linuxidc.com/Linux/2013-09/90638.htm
Django 的详细介绍:请点这里
Django 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-06/103380.htm
