Skip to content

Commit

Permalink
Fix django-taggit 1.0+ support
Browse files Browse the repository at this point in the history
The fix for has_changed() support in django-taggit changed the widget value:
jazzband/django-taggit@fa36187
A simple instance check allows this package to support both versions.
  • Loading branch information
vdboor committed Apr 12, 2019
1 parent 98f7b87 commit 0e9dca5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion taggit_selectize/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ def bool_or_str(val):
class TagSelectize(forms.TextInput):
def render(self, name, value, attrs=None, renderer=None):
if value is not None and not isinstance(value, six.string_types):
value = edit_string_for_tags([o.tag for o in value.select_related("tag")])
if isinstance(value, list):
# django-taggit 1.0 and up
value = edit_string_for_tags(value)
else:
# django-taggit 0.24.0 and below
value = edit_string_for_tags([o.tag for o in value.select_related("tag")])

html = super(TagSelectize, self).render(name, value, attrs)

js_plugins = []
Expand Down

0 comments on commit 0e9dca5

Please sign in to comment.