I use a model for the posts of my blog that you can see here(Is a my old post).
As you can see, in that moldel, I've an option to indicate highlighted post. If I use the code below to implement the pagination on my blog, also the highlighted post is sent in a page different from the first.
{% for post in posts %}
{% if post.highlighted == 1 %}
<h1><strong>Highlighted</strong></h1>
<a href="{{ post.get_absolute_url }}"><img src="{{ post.header_image }}" alt="Image of {{ post.title }}"></a>
<h1><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h1>
<h4>{{ post.tagline }}</h4>
{% endif %}
{% endfor %}
<hr><hr><hr>
{% for post in posts %}
{% if post.highlighted == 0 %}
<h1><strong>Not Highlighted</strong></h1>
<a href="{{ post.get_absolute_url }}"><img src="{{ post.header_image }}" alt="Image of {{ post.title }}"></a>
<h1><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h1>
<p>{{ post.tagline }}</p>
<h5>{{ post.publishing_date|date }}</h5>
{% for keyconcepts in post.keyconcepts.all %}
<a href="#">#{{ keyconcepts }}</a>
{% endfor %}
<hr>
{% endif %}
{% endfor %}
{% block pagination %}
{% if is_paginated %}
<div class="pagination px-auto">
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link text-center shadow" href="{{ request.path }}?page={{ page_obj.previous_page_number }}">Pagina precedente</a>
</li>
{% endif %}
<li class="page-item disabled">
<p class="page-link text-center shadow">Pagina {{ page_obj.number }} di {{ page_obj.paginator.num_pages }}.</p>
</li>
{% if page_obj.has_next %}
<li class="page-item">
<a class="page-link text-center shadow" href="{{ request.path }}?page={{ page_obj.next_page_number }}">Pagina successiva</a>
</li>
{% endif %}
</ul>
</nav>
</div>
{% endif %}
{% endblock %}
I would like to exclude all highlighted post from the pagination. Is it possible?
Below views.py
class ListPost(ListView):
model = Blog
context_object_name = 'posts'
queryset = Blog.objects.filter(category="G.I.S.") #FUNDAMENTAL FILTER
template_name = "blog/list_post.html"
paginate_by = 3
Note
Blog
seems a misnomer.BlogPost
seems more accurate.