Py学习  »  问与答

菜鸟贴 django-pagination 怎么用啊 总报request的错

msliudongsheng • 10 年前 • 7191 次点击  
Template error:
In template F:\django\panginationtest\panginationtest\templates\templates_pg.html, error at line 6
   request
   1 : <html>


   2 :     <body>


   3 :         <div>lds</div>


   4 :         <div>


   5 :         {% load pagination_tags %}


   6 :          {% autopaginate topics %}


   7 :         {% paginate %}


   8 : </div>


   9 :     </body>


   10 : </html>


   11 :

Traceback:
File "E:\python\lib\site-packages\django\core\handlers\base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "F:\django\panginationtest\panginationtest\views.py" in listing
  7.     return render_to_response('templates_pg.html', {"topics": topics})
File "E:\python\lib\site-packages\django\shortcuts\__init__.py" in render_to_response
  29.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "E:\python\lib\site-packages\django\template\loader.py" in render_to_string
  164.         return t.render(Context(dictionary))
File "E:\python\lib\site-packages\django\template\base.py" in render
  140.             return self._render(context)
File "E:\python\lib\site-packages\django\template\base.py" in _render
  134.         return self.nodelist.render(context)
File "E:\python\lib\site-packages\django\template\base.py" in render
  840.                 bit = self.render_node(node, context)
File "E:\python\lib\site-packages\django\template\debug.py" in render_node
  78.             return node.render(context)
File "E:\python\lib\site-packages\django_pagination-1.0.7-py2.7.egg\pagination\templatetags\pagination_tags.py" in render
  91.             page_obj = paginator.page(context['request'].page)
File "E:\python\lib\site-packages\django\template\context.py" in __getitem__
  56.         raise KeyError(key)

Exception Type: KeyError at /pagination/
Exception Value: 'request'
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/501
 
7191 次点击  
文章 [ 4 ]  |  最新文章 10 年前
olivetree
Reply   •   1 楼
olivetree    10 年前

用 local() 试试

jingzuo
Reply   •   2 楼
jingzuo    10 年前

就用自带的吧,简单方便。。

yafeile
Reply   •   3 楼
yafeile    10 年前

其实还是系统自带的那个比较好用。

Py站长
Reply   •   4 楼
Py站长    10 年前

看过 这篇 文章 了吗 http://django-china.cn/topic/53/