def user_logout request if request user is_anonymous return message Вы

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def user_logout(request):
if request.user.is_anonymous():
return message(u"Вы не авторизованы")
if request.user.is_authenticated():
logout(request)
return HttpResponseRedirect("/")
Получаю в консоль:
[01/Jul/2009 19:14:27] "GET /account/logout/ HTTP/1.1" 500 848
Traceback (most recent call last):
File "//usr/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)
File "//usr/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 636, in __call__
return self.application(environ, start_response)
File "//usr/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 245, in __call__
response = middleware_method(request, response)
File "//usr/lib/python2.5/site-packages/django/contrib/sessions/middleware.py", line 26, in process_response
patch_vary_headers(response, ('Cookie',))
File "//usr/lib/python2.5/site-packages/django/utils/cache.py", line 130, in patch_vary_headers
if response.has_header('Vary'):
AttributeError: 'dict' object has no attribute 'has_header'