Найти - Пользователи
Полная версия: 'SafeUnicode' object has no attribute 'has_header'
Начало » Django » 'SafeUnicode' object has no attribute 'has_header'
1
ypeskov
Добрый день,

потихоньку читаю djangobook.

пытаюсь изобразить код из 9й главый.

from django.template import loader, RequestContext

def custom_proc(request):
"A context processor that provides 'app', 'user' and 'ip_address'."
return {
'app': 'My app',
'user': request.user,
'ip_address': request.META['REMOTE_ADDR']
}

def view_1(request):
# ...
t = loader.get_template('template1.html')
c = RequestContext(request, {'message': 'I am view 1.'},
processors=[custom_proc])
return t.render(c)
в ответ в броузере получаю следующее:
Traceback (most recent call last):

File “/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py”, line 279, in run
self.result = application(self.environ, self.start_response)

File “/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py”, line 651, in __call__
return self.application(environ, start_response)

File “/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py”, line 245, in __call__
response = middleware_method(request, response)

File “/usr/lib/pymodules/python2.6/django/middleware/locale.py”, line 21, in process_response
patch_vary_headers(response, ('Accept-Language',))

File “/usr/lib/pymodules/python2.6/django/utils/cache.py”, line 130, in patch_vary_headers
if response.has_header('Vary'):

AttributeError: ‘SafeUnicode’ object has no attribute ‘has_header’
подскажите что бы это могло быть.
Александр Кошелев
В джангобуке ошибка - каждый вью должен возвращать HttpResponse, а не строку
return HttpResponse(t.render(c))
ypeskov
Благодарю покорно
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB