coding utf-8 from django http import HttpResponse from django conf imp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
from django.http import HttpResponse
from django.conf import settings
from jinja2 import FileSystemLoader, Environment
template_dirs = getattr(settings,'TEMPLATE_DIRS')
default_mimetype = getattr(settings, 'DEFAULT_CONTENT_TYPE')
env = Environment(loader=FileSystemLoader(template_dirs))
def render_to_response(filename, context={},mimetype=default_mimetype):
template = env.get_template(filename)
rendered = template.render(**context)
return HttpResponse(rendered,mimetype=mimetype)
потом делаю :
return render_to_response('blog/index.html', {'posts':posts, 'comments':last_comments})
и получаю:
Traceback (most recent call last):
File "//usr/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 279, in run
self.result = application(self.environ, self.start_response)
File "//usr/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 651, in __call__
return self.application(environ, start_response)
File "//usr/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
response = self.get_response(request)
File "//usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 134, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
File "//usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 154, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "//usr/lib/python2.5/site-packages/django/views/debug.py", line 40, in technical_500_response
html = reporter.get_traceback_html()
File "//usr/lib/python2.5/site-packages/django/views/debug.py", line 84, in get_traceback_html
self.get_template_exception_info()
File "//usr/lib/python2.5/site-packages/django/views/debug.py", line 117, in get_template_exception_info
origin, (start, end) = self.exc_value.source
ValueError: too many values to unpack