<commit_before>from django import forms
from django.utils.safestring import mark_safe
from django.core.urlresolvers import reverse
from taggit.forms import TagField
from taggit.utils import edit_string_for_tags


class TaggitLiveWidget(forms.TextInput):

    class Media:
        css = {'all': ('/static/taggit_live/css/taggit_live.css',
                       )}
        js = ('/static/taggit_live/js/taggit_live.js',
              )

    def render(self, name, value, attrs=None):
        if value is not None and not isinstance(value, basestring):
            value = edit_string_for_tags([o.tag for o in value.select_related("tag")])
        rendered = super(TaggitLiveWidget, self).render(name, value, attrs)
        url = reverse("taggit_autocomplete_list")
        js = u'<script type="text/javascript">(function($) { $("#%s").taggit_live({callback: "%s"}); })(jQuery || django.jQuery);</script>' % (attrs['id'], url)
        return rendered + mark_safe(js)


class LiveTagField(TagField):
    widget = TaggitLiveWidget<commit_msg>remove hardcoded STATIC_URL prefix from media files Django will figure this out by itself, of the urls do not start with a slash<commit_after>from django import forms
from django.utils.safestring import mark_safe
from django.core.urlresolvers import reverse
from taggit.forms import TagField
from taggit.utils import edit_string_for_tags


class TaggitLiveWidget(forms.TextInput):

    class Media:
        css = {'all': ('taggit_live/css/taggit_live.css',
                       )}
        js = ('taggit_live/js/taggit_live.js',
              )

    def render(self, name, value, attrs=None):
        if value is not None and not isinstance(value, basestring):
            value = edit_string_for_tags([o.tag for o in value.select_related("tag")])
        rendered = super(TaggitLiveWidget, self).render(name, value, attrs)
        url = reverse("taggit_autocomplete_list")
        js = u'<script type="text/javascript">(function($) { $("#%s").taggit_live({callback: "%s"}); })(jQuery || django.jQuery);</script>' % (attrs['id'], url)
        return rendered + mark_safe(js)


class LiveTagField(TagField):
    widget = TaggitLiveWidget
{'fraction_non_alphanumeric': 0.12183908045977011, 'fraction_numerical': 0.0, 'mean_word_length': 3.5239085239085237, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4471997', 'n_tokens_mistral': 660, 'n_tokens_neox': 644, 'n_words': 165}