报错: AttributeError: 'NoneType' object has no attribute 'split'

最近在写网站中遇到一个问题,就是题目上所写的:AttributeError: 'NoneType' object has no attribute 'split' 然后还有这样一行代码:self.status.split(' ',1)[0], self.bytes_sent ,大致意思就是说:返回的值是NoneType,split会报错?这里暂时先放着,不是很熟悉。这个问题困惑了我一天,怎么都想不到办法解决。

网上查到一个方法,因为我是写ajax代码时出现的这个问题,在ajax代码中加上'async' : false,这一行,表示不使用异步。当时有点疑惑,写ajax不就是为了异步吗?试着看能不能解决问题,果然可以。好吧就这样。。。但是浏览器返回了一个建议:“Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience”,有道翻译就是“不建议在主线程上使用同步XMLHttpRequest,因为它会对最终用户的体验产生有害影响”。

然后写到最后的时候,突然想到,我的js代码是从form表单中获取数据,当提交数据的时候默认的是form表单提交,得阻止默认的form表单提交,不然就会出现题目中的错误。所以js代码中写点击事件的时候,要注意是不是form表单里面提交:

xxxxBtn.click(function (event) {
event.preventDefault();
......
}
这样就不会报错了。

Django 报错总结的更多相关文章

  1. Django报错:OSError: raw write() returned invalid length 4 (should have been between 0 and 2)

    在使用Django时Django报错:Django报错:OSError: raw write() returned invalid length 4 (should have been between ...

  2. Django报错:提交表单报错---RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and you have APPEND_SLASH set.

    Django报错:提交表单报错---RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and ...

  3. django 报错Reverse for 'detail' with keyword arguments '{'pk': '2'}' not found. 1 pattern(s) tried: ['$post/(?P<pk>[0-9]+)/$']

    Django报错:Reverse for 'detail' with keyword arguments '{'pk': '2'}' not found. 1 pattern(s) tried: [' ...

  4. Django 报错 Reverse for 'content' not found. 'content' is not a valid view function or pattern name.

    Django 报错 Reverse for 'content' not found. 'content' is not a valid view function or pattern name. 我 ...

  5. ubuntu pip 安装django报错解决

    系统版本 ubuntu  Kylin 16.04 LTS       安装pip3 安装 Django 总是提示time out,无法安装. 逛了好多论坛终于遭到了解决办法,分享保存: sudo pi ...

  6. 关于Django报错django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configure

    报错代码:django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but se ...

  7. 记一次Django报错Reverse for 'indextwo' with no arguments not found. 1 pattern(s) tried: ['$index/$']

    启动python manage.py runserver 打开127.0.0.1:8000,报错信息如下: Reverse for 'indextwo' with no arguments not f ...

  8. django报错解决:view must be a callable or a list/tuple in the case of include().

    django版本:1.11.15 django应用,修改urls.py后,访问报错:TypeError at /view must be a callable or a list/tuple in t ...

  9. django报错解决:Invalid HTTP_HOST header: 'xxx.com'. You may need to add u'xxx.com' to ALLOWED_HOSTS.

    django版本:1.11.15 使用uwsgi+nginx运行django程序,出现报错,报错为:Invalid HTTP_HOST header: 'xxx.com:82'. You may ne ...

  10. django报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

    django 迁移数据库报错 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you ins ...

随机推荐

  1. Python的collections之defaultdict的使用及其优势

    user_dict = {} users = ["baoshan1", "baoshan2", "baoshan3","baosh ...

  2. 为什么在MySQL数据库中无法创建外键?(MyISAM和InnoDB详解)

    问题描述:为什么在MySQL数据库中不能创建外键,尝试了很多次,既没有报错,也没有显示创建成功,真实奇了怪,这是为什么呢? 问题解决:通过查找资料,每次在MySQL数据库中创建表时默认的情况是这样的: ...

  3. docker build doris-0.11.20-release source code

    1. pull doris dev docker image sudo docker pull apachedoris/doris-dev:build-env-1.1 2. dowload doris ...

  4. redis添加到linux系统服务

    http://blog.csdn.net/justfor3l/article/details/53187795

  5. 超文本css样式换行

    之前有关于LODOP中纯文本换行的相关博文:Lodop纯文本英文-等符号自动换行问题纯文本的遇到不拆分的单词的时候,可以通过LODOP 语句设置允许标点溢出,且英文单词拆开.超文本需要通过css样式控 ...

  6. Docker之使用Docker-compose搭建LNMP环境

    之前有随笔介绍使用Docker-compose搭建LNMP环境(centos6 php5.6) https://www.cnblogs.com/minseo/p/10146982.html 本文介绍D ...

  7. C# 需要引用MySql.Data.dll,请在Nuget安装最新稳定版本,如果有版本兼容问题请先删除原有引用 (SqlSugar)

    修改项目的app.config中的引用版本号即可

  8. linux系统 重启盘符错乱问题

    linux磁盘重启乱序问题处理 最近到客户那去巡检时,客户提到一个问题,他们的rac在重启的时候,原来的sda1.sdb1.sdc1会对应变成sdd1.sde1.sdf1,由于他们使用的是盘符来绑定裸 ...

  9. git当前项目免密提交

    在项目目录下,执行: vim .git/config 在url后边添加用户名密码即可 ``` [core] repositoryformatversion = filemode = true bare ...

  10. PHP 生成公钥私钥,加密解密,签名验签

    test_encry.php <?php //创建私钥,公钥 //create_key(); //要加密内容 $str = "test_str"; //加密 $encrypt ...