Created
December 8, 2014 10:18
-
-
Save mattions/26046fe94d51045e7663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if is_paginated %} | |
<div class="col-md-offset-4"> | |
<ul class="pagination pagination-centered"> | |
{% if page_obj.has_previous %} | |
<li><a href="?page=1"><<</a></li> | |
<li><a href="?{{queries.urlencode}}&page={{ page_obj.previous_page_number }}"><</a></li> | |
{% endif %} | |
{% for i in paginator.page_range %} | |
<li {% if page_obj.number == i %} class="active" {% endif %}><a href="?{{queries.urlencode}}&page={{i}}">{{i}}</a></li> | |
{% endfor %} | |
{% if page_obj.has_next %} | |
<li><a href="?{{queries.urlencode}}&page={{ page_obj.next_page_number }}">></a></li> | |
<li><a href="?{{queries.urlencode}}&page={{ page_obj.paginator.num_pages }}">>></a></li> | |
{% endif %} | |
</ul> | |
</div> | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_context_data(self, **kwargs): | |
context = super(ViewClassNameHere, self).get_context_data(**kwargs) | |
queries_without_page = self.request.GET.copy() | |
if queries_without_page.has_key('page'): | |
del queries_without_page['page'] | |
context['queries'] = queries_without_page | |
return context |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment