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 %} |
{% if is_paginated %} |
||||||
<nav> |
<nav> |
||||||
<ul class="pagination"> |
<ul class="pagination"> |
||||||
{% if page_obj.has_previous %} |
|
||||||
<li> |
<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> |
</li> |
||||||
{% endif %} |
|
||||||
|
|
||||||
{% for n in page_obj.paginator.page_range %} |
{% for n in page_obj.paginator.page_range %} |
||||||
{% if n == page_obj.number %} |
{% if n == page_obj.number %} |
||||||
<li class="i active"> |
<li class="active"><a href="#" onclick="return false">{{ n }}</a></li> |
||||||
<button type="submit" name="page" value="{{ n }}" class="i" disabled>{{ n }}</button> |
|
||||||
</li> |
|
||||||
{% else %} |
{% else %} |
||||||
<li> |
<li><a href="#" onclick="paginateTo({{ n }}); return false">{{ n }}</a></li> |
||||||
<button type="submit" name="page" value="{{ n }}">{{ n }}</button> |
|
||||||
</li> |
|
||||||
{% endif %} |
{% endif %} |
||||||
{% endfor %} |
{% endfor %} |
||||||
|
|
||||||
{% if page_obj.has_next %} |
|
||||||
<li> |
<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> |
</li> |
||||||
{% endif %} |
|
||||||
</ul> |
</ul> |
||||||
</nav> |
</nav> |
||||||
|
|
||||||
|
<script> |
||||||
|
function paginateTo(pageNum) { |
||||||
|
var urlObj = new URI(location.href) |
||||||
|
urlObj.setQuery('page', pageNum) |
||||||
|
location.href = urlObj.href() |
||||||
|
} |
||||||
|
</script> |
||||||
{% endif %} |
{% endif %} |
||||||
|
|||||||
Loading…
Reference in new issue