parent
61d73035b6
commit
c5c94ba6c9
21 changed files with 596 additions and 491 deletions
@ -1,9 +0,0 @@ |
||||
from django.shortcuts import _get_queryset |
||||
|
||||
def get_or_none(klass, *args, **kwargs): |
||||
queryset = _get_queryset(klass) |
||||
|
||||
try: |
||||
return queryset.get(*args, **kwargs) |
||||
except queryset.model.DoesNotExist: |
||||
return None |
||||
@ -1,29 +1,51 @@ |
||||
{% if is_paginated %} |
||||
<nav> |
||||
<ul class="pagination"> |
||||
{% if page_obj.has_previous %} |
||||
<li> |
||||
<button type="submit" name="page" value="{{ page_obj.previous_page_number }}">Previous</button> |
||||
<a |
||||
href="#" |
||||
aria-label="Previous" |
||||
|
||||
{% if page_obj.has_previous %} |
||||
onclick="paginateTo({{ page_obj.previous_page_number }}); return false" |
||||
{% else %} |
||||
onclick="return false" |
||||
style="cursor: not-allowed" |
||||
{% endif %}> |
||||
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> |
||||
</a> |
||||
</li> |
||||
{% endif %} |
||||
|
||||
{% for n in page_obj.paginator.page_range %} |
||||
{% if n == page_obj.number %} |
||||
<li class="i active"> |
||||
<button type="submit" name="page" value="{{ n }}" class="i" disabled>{{ n }}</button> |
||||
</li> |
||||
<li class="active"><a href="#" onclick="return false">{{ n }}</a></li> |
||||
{% else %} |
||||
<li> |
||||
<button type="submit" name="page" value="{{ n }}">{{ n }}</button> |
||||
</li> |
||||
<li><a href="#" onclick="paginateTo({{ n }}); return false">{{ n }}</a></li> |
||||
{% endif %} |
||||
{% endfor %} |
||||
|
||||
{% if page_obj.has_next %} |
||||
<li> |
||||
<button type="submit" name="page" value="{{ page_obj.next_page_number }}">Next</button> |
||||
<a |
||||
href="#" |
||||
aria-label="Next" |
||||
|
||||
{% if page_obj.has_next %} |
||||
onclick="paginateTo({{ page_obj.next_page_number }}); return false" |
||||
{% else %} |
||||
onclick="return false" |
||||
style="cursor: not-allowed" |
||||
{% endif %}> |
||||
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> |
||||
</a> |
||||
</li> |
||||
{% endif %} |
||||
</ul> |
||||
</nav> |
||||
|
||||
<script> |
||||
function paginateTo(pageNum) { |
||||
var urlObj = new URI(location.href) |
||||
urlObj.setQuery('page', pageNum) |
||||
location.href = urlObj.href() |
||||
} |
||||
</script> |
||||
{% endif %} |
||||
|
||||
Loading…
Reference in new issue