Skip to content

Commit

Permalink
Django >=1.10 - Widget - Move from Context to dict
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulwahid24 committed Jan 3, 2019
1 parent aac755f commit affcde2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions django_hstore/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ def render(self, name, value, attrs=None):
html = super(BaseAdminHStoreWidget, self).render(name, value, attrs)

# prepare template context
template_context = Context({
template_context = {
'field_name': name,
'STATIC_URL': settings.STATIC_URL,
'use_svg': django.VERSION >= (1, 9), # use svg icons if django >= 1.9
})
}
if django.VERSION < (1, 10):
template_context = Context(template_context)

# get template object
template = get_template('hstore_%s_widget.html' % self.admin_style)
# render additional html
additional_html = template.render(template_context)
additional_html = template.render(context=template_context)

# append additional HTML and mark as safe
html = html + additional_html
Expand Down

0 comments on commit affcde2

Please sign in to comment.