我正在尝试使用django-endless-pagination在滚动上实现连续分页.
页面的初始渲染工作正常.但是,滚动后,整个 html页面内容将加载到endless_page_template div中,而不是page_template中所需的部分html内容.结果有点像在镜子里面反射另一面镜子.我相信返回的查询集是正确的,因为在不尝试使用"paginateOnScroll"时分页结果是正确的.
我的观点的相关部分如下.我正在使用CreateView,因为我在与分页注释相同的页面上有注释表单.
class MyIndex(CreateView): form_class = CommentForm template_name = 'my/index.html' page_template = 'my/comments.html' def get_context_data(self, **kwargs): context = super(MyIndex, self).get_context_data(**kwargs) context.update({ 'comments': Comment.objects.order_by('-id').filter(parent=None), 'page_template': self.page_template, }) return context
我/ index.html模板的相关部分(主模板)
{% include page_template %}
我/ comments.html的相关部分(page_template)
{% load endless %} {% paginate comments %} {% for comment in comments %} {{ comment.name }} {{ comment.message}} {% if not forloop.last %}
{% endif %} {% endfor %}
{% show_more %}
谢谢!