报错: 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. Java8中的日期时间类

    测试类: import java.time.*; import java.time.format.DateTimeFormatter; public class App { public static ...

  2. ubuntu系统TCP连接参数优化-TIME_WAIT过多解决办法

    状态:描述CLOSED:无连接是活动的或正在进行LISTEN:服务器在等待进入呼叫SYN_RECV:一个连接请求已经到达,等待确认SYN_SENT:应用已经开始,打开一个连接ESTABLISHED:正 ...

  3. Springboot项目mysql日期存储不匹配问题和在idea本地可以运行起来,但打包jar后运行报找不到mysql驱动的解决方案

    修改pop.xml中scope的值,如果是具体版本号,修改为如下即可解决 <dependency> <groupId>mysql</groupId> <art ...

  4. linux传输文件lrzsz

    linux传输文件

  5. LeetCode_219. Contains Duplicate II

    219. Contains Duplicate II Easy Given an array of integers and an integer k, find out whether there ...

  6. 修改config中的assemblyBinding

    修改config中的assemblyBinding 未测试这段代码 private void SetRuntimeBinding(string path, string value) { XmlDoc ...

  7. WebException 请求被中止: 操作超时

    HTTP 请求时出现 :WebException 请求被中止: 操作超时 处理HTTP请求的服务器 CPU 100% ,重启后正常.

  8. Appium移动自动化测试-----(七)Desired Capabilities

    Desired Capabilities Desired Capabilities 在启动 session 的时候是必须提供的. Desired Capabilities 本质上是以 key valu ...

  9. 守护进程daemon

    # -*- coding: utf-8 -*- import sys, os, time, atexit from signal import SIGTERM class Daemon: def __ ...

  10. LeetCode 53. 最大子序和(Maximum Subarray)

    53. 最大子序和 53. Maximum Subarray 题目描述 给定一个整数数组 nums,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和. LeetCode53. M ...