我有运行1.3.1版本的django代码,最近我将它更新到django 1.6.1,并清除了大多数错误,如direct_to_template函数和一些settings等,并能够运行该网站。
但是对于某些页面,当它在模板中遇到{% autopaginate object_list 20 %}标记时,我会得到下面的错误
我使用django-pagination(1.0.7)实现我的分页功能
Request Method: GET
Request URL: http://localhost:8000/reports/safety/
Django Version: 1.6.1
Exception Type: KeyError
Exception Value:
'request'
Exception Location: /home/user/.virtualenvs/proj/local/lib/python2.7/site-packages/django/template/context.py in __getitem__, line 56
Python Executable: /home/user/.virtualenvs/proj/bin/python
Python Version: 2.7.4
......
........
Error during template rendering
In template /home/user/users/apps/proj/templates/shared/report.html, error at line 41
request
40 <tbody>
41 {% autopaginate object_list 20 %}
42 {% for report in object_list %}
43 {{report}}
44 ........
.........
{% endfor %}
100 </tbody>所以谁能让我知道为什么会出现上面的错误,以及如何清除它?
发布于 2014-01-29 20:30:48
啊,其实需要在TEMPLATE_CONTEXT_PROCESSORS设置中添加"django.core.context_processors.request",设置
https://stackoverflow.com/questions/21430739
复制相似问题