django 中的分页不是按每页 6 个帖子对帖子进行分页

Pagination in django not pagination the posts by 6 posts per page

在 django 中为我的分页编写视图后,该按钮工作正常,这意味着它们加载了新的 pagesz 但问题是所有帖子仍然保留在所有新页面中,这不是预期的。 views.py

def ElementLists(request):
    vectors = Vectors.objects.filter(status="published").order_by("?")
    paginator = Paginator(vectors, 6)
    page_number = request.GET.get('page')
    vector_paginator = paginator.get_page(page_number)

elementlist.html

<li class="page-item">
   {% if vector_paginator.has_previous %}
      <a class="page-link" href="?page={{vector_paginator.previous_page_number}}" arialabel="Previous">
      <span class="ti-arrow-left">Previous</span>
      <span class="sr-only">Previous</span>
      </a>
   {% endif %}
</li>


<li class="page-item">
   {% if vector_paginator.has_next %}
       <a class="page-link" href="?page={{vector_paginator.next_page_number}}" aria-label="Next">
       <span class="ti-arrow-right">Load More</span>
       <span class="sr-only">Next</span>
       </a>
   {% endif %}
</li>

我后来得到了修复 在模板中循环浏览您的帖子时,现在应该是这个

之前

{% for post in posts %}
    ...code here
{% endfor %}

现在

{% for post in posts_paginator %}
    ...code here
{% endfor %}