Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions pagination/templatetags/pagination_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.http import Http404
from django.core.paginator import Paginator, InvalidPage
from django.conf import settings
from django.template.context import RequestContext, Context

register = template.Library()

Expand Down Expand Up @@ -204,23 +205,25 @@ def paginate(context, window=DEFAULT_WINDOW, hashtag=''):
differenced = list(last.difference(current))
differenced.sort()
pages.extend(differenced)
to_return = {
'MEDIA_URL': settings.MEDIA_URL,
'pages': pages,
'records': records,
'page_obj': page_obj,
'paginator': paginator,
'hashtag': hashtag,
'is_paginated': paginator.count > paginator.per_page,
}
to_return = Context()
to_return.update(context)
to_return.update({
'MEDIA_URL': settings.MEDIA_URL,
'pages': pages,
'records': records,
'page_obj': page_obj,
'paginator': paginator,
'hashtag': hashtag,
'is_paginated': paginator.count > paginator.per_page,
})
if 'request' in context:
getvars = context['request'].GET.copy()
if 'page' in getvars:
del getvars['page']
if len(getvars.keys()) > 0:
to_return['getvars'] = "&%s" % getvars.urlencode()
to_return.update({'getvars': '&%s' % getvars.urlencode()})
else:
to_return['getvars'] = ''
to_return.update({'getvars': ''})
return to_return
except KeyError, AttributeError:
return {}
Expand Down