Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django none type object has no attribute status

Tags:

python

django

I get the following error from Django:

NoneType object has no attribute status_code

Here's a copy of the output from the log:

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'
like image 777
ravi Avatar asked Nov 26 '22 17:11

ravi


2 Answers

The view that serves the institutes_admin URL is not returning a response, so the middleware is dying when it tries to cache it. You need to post the code of that view - and please do it here, not on a separate paste site.

like image 129
Daniel Roseman Avatar answered Dec 09 '22 04:12

Daniel Roseman


Somewhere you've lost your response object.

If autologout has a process_response method, I'd look there. If you add the code of autologout and the view, it'll probably be very fast to find the problem.

like image 28
Ted Avatar answered Dec 09 '22 06:12

Ted