diff --git a/README.txt b/README.txt index acb2d47..f4848cf 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,19 @@ +This is a fork of django-tagging! + +(http://code.google.com/p/django-tagging/ + or +http://github.com/clones/django-tagging) + +THE MAIN AND CURRENTLY ONLY DIFFERENCE TO THE ORIGIN BRANCH IS THAT +THERE IS A SETTINGS OPTION CALLED + +FORCE_COMMA_SEPARATOR + +IF ITS TRUE; django-tagging USES COMMA AS SEPARATOR ALWAYS! +I NEED THIS FOR django-tagging-autocomplete! + + + ============== Django Tagging ============== @@ -7,4 +23,4 @@ This is a generic tagging application for Django projects For installation instructions, see the file "INSTALL.txt" in this directory; for instructions on how to use this application, and on what it provides, see the file "overview.txt" in the "docs/" -directory. \ No newline at end of file +directory. diff --git a/tagging/settings.py b/tagging/settings.py index 1d6224c..cceaf78 100644 --- a/tagging/settings.py +++ b/tagging/settings.py @@ -11,3 +11,7 @@ # Whether to force all tags to lowercase before they are saved to the # database. FORCE_LOWERCASE_TAGS = getattr(settings, 'FORCE_LOWERCASE_TAGS', False) + +#If its True comme is used separator always.(ie for AutoCompleteTagField) +FORCE_COMMA_SEPARATOR = getattr(settings, 'FORCE_COMMA_SEPARATOR', False) + diff --git a/tagging/utils.py b/tagging/utils.py index e89bab0..9285603 100644 --- a/tagging/utils.py +++ b/tagging/utils.py @@ -8,6 +8,7 @@ from django.db.models.query import QuerySet from django.utils.encoding import force_unicode from django.utils.translation import ugettext as _ +import settings # Python 2.3 compatibility try: @@ -31,7 +32,7 @@ def parse_tag_input(input): # Special case - if there are no commas or double quotes in the # input, we don't *do* a recall... I mean, we know we only need to # split on spaces. - if u',' not in input and u'"' not in input: + if u',' not in input and u'"' not in input and not settings.FORCE_COMMA_SEPARATOR : words = list(set(split_strip(input, u' '))) words.sort() return words @@ -75,10 +76,11 @@ def parse_tag_input(input): saw_loose_comma = True to_be_split.append(u''.join(buffer)) if to_be_split: - if saw_loose_comma: + if saw_loose_comma or settings.FORCE_COMMA_SEPARATOR: delimiter = u',' else: delimiter = u' ' + for chunk in to_be_split: words.extend(split_strip(chunk, delimiter)) words = list(set(words)) @@ -110,7 +112,7 @@ def edit_string_for_tags(tags): it will be space-delimited. """ names = [] - use_commas = False + use_commas = settings.FORCE_COMMA_SEPARATOR for tag in tags: name = tag.name if u',' in name: