Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing entire context to pagination.html #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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