阅读django-endless-pagination的文档它说你可以通过使用@page_template()装饰器将它的Ajax分页功能扩展到基于类的视图。 。 我一直在尝试使用以实施装饰的像一小时:使用django-endless-pagination自定义基于扩展ListView的基于c的视图
class ExtendedListView(ListView):
template_name = 'global_template.html'
@method_decorator(@page_template('path_to_updatable_content_only_template'))
def dispatch(self, *args, **kwargs):
return super(ExtendedListView, self).dispatch(*args, **kwargs)
视图功能不输出任何错误,但是当我去到另一个网页加载目标中的“global_template”和不是在装饰器中定义的模板。
如果有人知道这个实现是否真正起作用,并且我犯了一些错误,请指出,我很乐意以正确的方式使用它。
我已经设法拿出一个workarround所以如果someoene的得到了同样的问题,有没有标准的答案,这一点,你可以这样做:
class ExtendedListView(ListView):
template_name='global_template_path'
'''
render_to_response ¿hack? so that i can render only the updatable DOM part template
'''
def render_to_response(self, context):
if self.request.is_ajax():
self.template_name = 'path_to_updatable_content_only_template'
return super(ExtendedListView, self).render_to_response(context)
else:
return super(ExtendedListView, self).render_to_response(context)
干杯!
我的问题是试图让多个分页工作。 – acjay 2012-09-26 22:06:20