11import re
22
3+ import django
34from django .core .urlresolvers import reverse , NoReverseMatch
4- from django .template import Context , Node , Library , TemplateSyntaxError , VariableDoesNotExist
5+ from django .template import Node , Library , TemplateSyntaxError , VariableDoesNotExist
56from django .template .loader import get_template
67from django .conf import settings
78from django .http import QueryDict
89from django .utils .html import mark_safe
910
11+
12+ # As of django 1.10, template rendering no longer accepts a context, but
13+ # instead accepts only accepts a dict. Up until django 1.8, a context was
14+ # actually required. Fortunately Context takes a single dict parameter,
15+ # so for django >=1.9 we can get away with just passing a unit function.
16+ if django .VERSION < (1 , 9 , 0 ):
17+ from django .template import Context
18+ else :
19+ def Context (x ):
20+ return x
21+
22+
1023register = Library ()
1124
1225
@@ -93,15 +106,15 @@ def render(self, context):
93106 next_page_url = get_page_url (page .next_page_number (), context .current_app , url_view_name , url_extra_args , url_extra_kwargs , url_param_name , url_get_params , url_anchor )
94107
95108 return get_template ("bootstrap_pagination/pager.html" ).render (
96- {
109+ Context ( {
97110 'page' : page ,
98111 'previous_label' : previous_label ,
99112 'next_label' : next_label ,
100113 'previous_title' : previous_title ,
101114 'next_title' : next_title ,
102115 'previous_page_url' : previous_page_url ,
103116 'next_page_url' : next_page_url
104- })
117+ }))
105118
106119
107120class BootstrapPaginationNode (Node ):
@@ -208,7 +221,7 @@ def render(self, context):
208221 next_page_url = get_page_url (page .next_page_number (), context .current_app , url_view_name , url_extra_args , url_extra_kwargs , url_param_name , url_get_params , url_anchor )
209222
210223 return get_template ("bootstrap_pagination/pagination.html" ).render (
211- {
224+ Context ( {
212225 'page' : page ,
213226 'size' : size ,
214227 'show_index_range' : show_index_range ,
@@ -223,7 +236,7 @@ def render(self, context):
223236 'last_page_url' : last_page_url ,
224237 'previous_page_url' : previous_page_url ,
225238 'next_page_url' : next_page_url
226- })
239+ }))
227240
228241
229242@register .tag
0 commit comments