python - styling issue in navigation bar with django -
i have styling issue in navigation bar
when next button enabled, has issue
error in next page button:
but when button disabled, got fixed
error fixed:
here code navigation.html
<div class="col-6 col-offset-3 text-center pagination-set"> <nav aria-label=""> {% if queryset.has_other_pages %} <ul class="pagination"> {% if queryset.has_previous %} <li class="page-item"> <a class="page_link" href="?page={{ queryset.previous_page_number }}">«</a> </li> {% else %} <li class="page-item disabled"> <a class="page-link"><span class="page-link">«</span></a> </li> {% endif %} {% in page_range %} {% if queryset.numbers == %} <li class="page-item active"> <a class="page-link">{{ }} <span class="src-only">(current) </span> </a> </li> {% else %} <li class="page-item"> <a class="page-link" href="?page={{ }}">{{ }}</a> </li> {% endif %} {% endfor %} {% if queryset.has_next %} <li class="page-item"> <a class="page-link" href="?page={{queryset.next_page_number}}"></a>» </li> {% else %} <li class="page-item disabled"> <a class="page-link"><span>»</span></a> </li> {% endif %} </ul> </nav> </div>
{% endif %}
and code pagination in views.py:
paginator = paginator(queryset_list, 2) # show 2 contacts per page page = request.get.get('page') try: queryset = paginator.page(page) except pagenotaninteger: # if page not integer, deliver first page. queryset = paginator.page(1) except emptypage: # if page out of range (e.g. 9999), deliver last page of results. queryset = paginator.page(paginator.num_pages) index = queryset.number -1 max_index = len(paginator.page_range) start_index = index - 5 if index <= max_index - 5 else 0 end_index = index + 5 if index <= max_index - 5 else max_index page_range = paginator.page_range[start_index:end_index]
i grab code django documentaion
Comments
Post a Comment