Reputation: 173
Sorry because of the dumb question. I am reading a tutorial from book called build django 2 web application. and I get to the pagination topic but I can't get why it does not working even when I am copy-pasting carefully.
{% if is_paginated %}
<nav>
<ul class="pagination">
<li class="page-item">
<a href="{% url 'core:MovieList'%}?page=1" class="page- link">First</a>
</li>
{% if page_obj.has_previous %}
<li class="page-item">
<a href="{% url 'core:MovieList' %}?page={{page_obj.previous_page_number}}" class="page-link">{{page_obj.previous_page_number}}</a>
</li>
{% endif %}
<li class="page-item active">
<a href="{% url 'core:MovieList' %}?page={{page_obj.number}}" class="page-link">{{page_obj.number}}</a>
</li>
{% if page_obj.has_next %}
<li class="page-item">
<a href="{% url 'core:MovieList' %}?page={{page_obj.next_page_number}}" class="page-link">{{page_obj.next_page_number}}</a>
</li>
{% endif %}
<li class="page-item">
<a href="{% url 'core:MovieList' %}?page={{paginator.num_pages}}" class="page-link">Last</a>
</li>
</ul>
</nav>
{% endif %}
#View
class MovieListView(ListView):
model = Movie
template_name = 'movie_list.html'
Upvotes: 0
Views: 143
Reputation: 599956
You haven't set the paginated_by
attribute in the view class, so the contents won't be paginated.
class MovieListView(ListView):
model = Movie
template_name = 'movie_list.html'
paginate_by = 5
Upvotes: 1