Skip to content

Commit b242a70

Browse files
authored
Merge pull request #27 from blueicepl/django_1_10
django 1.10 compatibility on replacing Context with dict
2 parents 5c882df + dd417b0 commit b242a70

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

django_forms_bootstrap/templatetags/bootstrap_tags.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
from django import template
2-
from django.template import Context
32
from django.template.loader import get_template
3+
from django import VERSION as DJANGO_VERSION
44

55

6+
if DJANGO_VERSION >= (1, 10, 0):
7+
context_class = dict
8+
else:
9+
# Django<1.10 compatibility
10+
from django.template import Context
11+
context_class = Context
12+
613
register = template.Library()
714

815

@@ -22,7 +29,7 @@ def as_bootstrap(form):
2229
template = get_template("bootstrap/form.html")
2330
form = _preprocess_fields(form)
2431

25-
c = Context({
32+
c = context_class({
2633
"form": form,
2734
})
2835
return template.render(c)
@@ -44,7 +51,7 @@ def as_bootstrap_inline(form):
4451
"wrap": "",
4552
}
4653

47-
c = Context({
54+
c = context_class({
4855
"form": form,
4956
"css_classes": css_classes,
5057
})
@@ -81,7 +88,7 @@ def as_bootstrap_horizontal(form, label_classes=""):
8188
css_classes["single_container"] += offset_class + " " + wrap_class + " "
8289
css_classes["wrap"] += wrap_class + " "
8390

84-
c = Context({
91+
c = context_class({
8592
"form": form,
8693
"css_classes": css_classes,
8794
})

0 commit comments

Comments
 (0)