python - django none 类型对象没有属性状态

标签 python django

我从 Django 得到以下错误:

NoneType object has no attribute status_code

这是日志输出的副本:

Environment:

Request Method: GET
Request URL: http://192.168.2.206:8080/institutes_admin/
Django Version: 1.1.1
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.admin',
 'django.contrib.contenttypes',
 'django.contrib.markup',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.comments',
 'mysite.registration',
 'mysite.profiles',
 'mysite.epw',
 'mysite.remember_me',
 'mysite.avatar',
 'mysite.django_documents',
 'mysite.inlines',
 'mysite.blog',
 'mysite.forum',
 'tagging']
Installed Middleware:
('django.middleware.cache.UpdateCacheMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.cache.FetchFromCacheMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'mysite.remember_me.views.AutoLogout')


Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/pymodules/python2.6/django/utils/decorators.py" in _wrapped_view
  56.                 result = middleware.process_response(request, response)
File "/usr/lib/pymodules/python2.6/django/middleware/cache.py" in process_response
  80.         if not response.status_code == 200:

Exception Type: AttributeError at /institutes_admin/
Exception Value: 'NoneType' object has no attribute 'status_code'

最佳答案

服务于 institutes_admin URL 的 View 没有返回响应,所以中间件在尝试缓存它时快要死了。您需要发布该 View 的代码 - 请在此处进行,而不是在单独的粘贴站点上进行。

关于python - django none 类型对象没有属性状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4222925/

相关文章:

Django 模型选择

Python代码查找所有从/目录开始的目录/子目录中所有新建、修改和删除的文件

python - 使用参数从 bash 调用 Python 脚本

Python 'with' 不删除对象

python - 在 numpy 中将 3d 数组合并为 4d 数组

PYTHON 从嵌套列表中删除元素

javascript - 服务器端或 Javascript 计算?

python - 在 Daphne - SSL 上使用 channel 部署 django 应用程序

python - 本地文件系统作为 Django 中的远程存储

python - 如何在 Django 中快速选择经纬度范围?