0

我有运行1.3.1版本的 django 代码,最近我将它更新到 django1.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>

那么谁能告诉我为什么会出现上述错误以及如何清除它?

4

1 回答 1

1

啊,实际上需要"django.core.context_processors.request",在 TEMPLATE_CONTEXT_PROCESSORS 设置中添加设置

于 2014-01-29T12:30:47.727 回答