1.安装django报错解决方案  

找到第一条报错信息:
  File "c:\users\chenwei\envs\testvir2\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args)    
  出错原因:UnicodeEncodeError: 'ascii' codec can't encode character u'\u258f' in position 8: ordinal not in range(128)
  在报错文件:c:\users\chenwei\envs\testvir2\lib\site-packages\pip\basecommand.py 中加如下代码:

  1. import sys
  2. reload(sys)
  3. sys.setdefaultencoding('gbk')

2.错误2:RuntimeError: maximum recursion depth exceeded

  1. 解决方案:
  2. To fix the problem replace this (about line 56 in python\Lib\fuctools.py):
  3. convert = {
  4. '__lt__': [('__gt__', lambda self, other: other < self),
  5. ('__le__', lambda self, other: not other < self),
  6. ('__ge__', lambda self, other: not self < other)],
  7. '__le__': [('__ge__', lambda self, other: other <= self),
  8. ('__lt__', lambda self, other: not other <= self),
  9. ('__gt__', lambda self, other: not self <= other)],
  10. '__gt__': [('__lt__', lambda self, other: other > self),
  11. ('__ge__', lambda self, other: not other > self),
  12. ('__le__', lambda self, other: not self > other)],
  13. '__ge__': [('__le__', lambda self, other: other >= self),
  14. ('__gt__', lambda self, other: not other >= self),
  15. ('__lt__', lambda self, other: not self >= other)]
  16. }
  17. to that:
  18. convert = {
  19. '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
  20. ('__le__', lambda self, other: self < other or self == other),
  21. ('__ge__', lambda self, other: not self < other)],
  22. '__le__': [('__ge__', lambda self, other: not self <= other or self == other),
  23. ('__lt__', lambda self, other: self <= other and not self == other),
  24. ('__gt__', lambda self, other: not self <= other)],
  25. '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
  26. ('__ge__', lambda self, other: self > other or self == other),
  27. ('__le__', lambda self, other: not self > other)],
  28. '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
  29. ('__gt__', lambda self, other: self >= other and not self == other),
  30. ('__lt__', lambda self, other: not self >= other)]
  31. }

3.在python中run manage.py 链接数据库报错:No name mysqlDB

  1. 解决方案:pip install mysql-python

4.安装mysql-python报错

错误提示:
    error: command '"C:\Users\chenwei\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe"' failed with exit status2

  1. 解决方案:
  2. http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python下载对应的包版本
  3.  
  4. pip2 install MySQL_python-1.2.5-cp27-none-win_amd64.whl
  5. 注意:cp27说明要用python2.7来安装,所以要用pip2

5.执行python2 manage.py runserver 0.0.0.0:8000出错

  1. Traceback (most recent call last):
  2. File "manage.py", line 10, in <module>
  3. execute_from_command_line(sys.argv)
  4. File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from
  5. utility.execute()
  6. File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 355, in execute
  7. self.fetch_command(subcommand).run_from_argv(self.argv)
  8. File "C:\Python27\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
  9. self.execute(*args, **cmd_options)
  10. File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 62, in exe
  11. super(Command, self).execute(*args, **options)
  12. File "C:\Python27\lib\site-packages\django\core\management\base.py", line 330, in execute
  13. output = self.handle(*args, **options)
  14. File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 101, in ha
  15. self.run(**options)
  16. File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 110, in ru
  17. autoreload.main(self.inner_run, None, options)
  18. File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 341, in main
  19. reloader(wrapped_main_func, args, kwargs)
  20. File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 312, in python_reloader
  21. exit_code = restart_with_reloader()
  22. File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 294, in restart_with_reloade
  23. str_value = force_bytes(new_environ[key], encoding=encoding)
  24. File "C:\Python27\lib\site-packages\django\utils\encoding.py", line 124, in force_bytes
  25. return s.decode('utf-8', errors).encode(encoding, errors)
  26. File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
  27. return codecs.utf_8_decode(input, errors, True)
  28. UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 15: invalid continuation byte

解决方案:

  1. manage.py 开头加上
  2. import sys
  3. reload(sys)
  4. sys.setdefaultencoding('utf-8')

6.当创建的app比较多时,将多个app存放在一个文件夹apps下,提示找不到文件路径

  python manage.py runserver 0.0.0.0:8000

  解决方案:

  1. settins文件中,添加sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))

7.Django “Cannot add or update a child row: a foreign key constraint fails”

  解决方案:

  1. settins
  2. DATABASES = {
  3. 'default': {
  4. ...
  5. 'OPTIONS': {
  6. "init_command": "SET foreign_key_checks = 0;",
  7. },
  8. }
  9. }

8.通过源码安装xadmin,执行manage.py时,报找不到xadmin模块

解决方案:将xadmin添加到搜索路径下。

9.django.core.exceptions.ImproperlyConfigured: Application names aren't unique, duplicates: my_app01

 解决方案一:

    在settings中,删除掉你注册的应用:

 解决方案二:

   找到你所写的应用app01---->把apps.py文件中的代码全部注释掉。即可解决问题 

10.'WSGIRequest' object has no attribute 'user'

  将settings中配置的MIDDLEWARE改为MIDDLEWARE_CLASSES

  1. MIDDLEWARE = [
  2. 'django.middleware.security.SecurityMiddleware',
  3. 'django.contrib.sessions.middleware.SessionMiddleware',
  4. 'django.middleware.common.CommonMiddleware',
  5. 'django.middleware.csrf.CsrfViewMiddleware',
  6. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  7. 'django.contrib.messages.middleware.MessageMiddleware',
  8. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  9. ]

  

Django错误大汇总的更多相关文章

  1. 大礼包!ANDROID内存优化(大汇总)

    写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上把网上搜集的各种内存零散知识点进行汇总.挑选.简化后整理而成. 所以我将本文定义为一个工具类的文章,如果你在A ...

  2. android app性能优化大汇总(内存性能优化)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上 ...

  3. ANDROID内存优化——大汇总(转)

    原文作者博客:转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! ANDROID内存优化(大汇总——上) 写在最前: 本文的思路主要借鉴了20 ...

  4. ANDROID内存优化(大汇总——中)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上 ...

  5. ANDROID内存优化(大汇总——上)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上 ...

  6. C/C++ 笔试、面试题目大汇总 转

    C/C++ 笔试.面试题目大汇总 这些东西有点烦,有点无聊.如果要去C++面试就看看吧.几年前网上搜索的.刚才看到,就整理一下,里面有些被我改了,感觉之前说的不对或不完善. 1.求下面函数的返回值( ...

  7. 转 C语言面试题大汇总

    转 C语言面试题大汇总,个人觉得还是比较全地!!! \主 题:   C语言面试题大汇总,个人觉得还是比较全地!!!  作 者:   free131 (白日?做梦!)   信 誉 值:   100    ...

  8. java面试笔试大汇总

    java面试笔试题大汇总5 JAVA相关基础知识 1.面向对象的特征有哪些方面 1.抽象:2.继承:3.封装:4. 多态性: 2.String是最基本的数据类型吗? 基本数据类型包括byte.int. ...

  9. 实用的vue插件大汇总

    Vue是一个构建数据驱动的 web 界面的渐进式框架.Vue.js 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件特别整理了常用的vue插件,来了个大汇总,方便查找使用,便于工作 ...

随机推荐

  1. Why are Eight Bits Enough for Deep Neural Networks?

    Why are Eight Bits Enough for Deep Neural Networks? Deep learning is a very weird technology. It evo ...

  2. 超酷动态图片展示墙JS特效制作方法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. JQuery和Servlet来实现跨域请求

    在网上看到很多的JQuery跨域请求的文章,比较有意思.这里我发表一个Servlet与JQuery配置实现跨域的代码,供大家参考.不足之处请指教 原理:JavaScript的Ajax不可以跨域,但是可 ...

  4. flume监控一个linux指定的一个文件夹的文件信息

    1.编辑一个配置文件 flume-app.conf  拷贝至fulme的安装目录的conf下 # The configuration file needs to define the sources, ...

  5. 用Vue来实现图片上传多种方式

    没有业务场景的功能都是耍流氓,那么我们先来模拟一个需要实现的业务场景.假设我们要做一个后台系统添加商品的页面,有一些商品名称.信息等字段,还有需要上传商品轮播图的需求. 我们就以Vue.Element ...

  6. 吐泡泡(2018年全国多校算法寒假训练营练习比赛(第二场)+栈模拟)+Plug-in(codeforces81A+栈模拟)

    吐泡泡题目链接:https://www.nowcoder.com/acm/contest/74/A 题目: 思路: 这种题目当初卡了我很久,今天早训时遇到一个一样得题,一眼就想到用栈模拟,就又回来把这 ...

  7. HDU 2067 小兔的棋盘 (模拟)

    题目链接 Problem Description 小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己的房间,拆开一看是一个棋盘,小兔有所失望.不过没过几天发现了棋盘的好玩之处.从起点(0, ...

  8. LeetCode之数据流中第一个唯一的数字

    使用一个Map维护数字出现的次数,使用一个链表维护只出现一次的数,使用一个变量记录是否找到过终止数字. AC代码: public class Solution { /* * @param : a co ...

  9. Python3中的SocketServer

    socket并不能多并发,只能支持一个用户,socketserver 简化了编写网络服务程序的任务,socketserver是socket的在封装.socketserver在python2中为Sock ...

  10. 高性能优秀的服务框架-dubbo介绍

    先来了解一下这些年架构的变化,下面的故事是我编的.... "传统架构":很多年前,刚学完JavaWeb开发的我凭借一人之力就开发了一个网站,网站 所有的功能和应用都集中在一起,方便 ...