Simple runner
Simple runner

Reputation: 445

Django-taggit tags with whitespace in name?

How can I use tags with whitespace char in their name with django-taggit? For example, "Some simple tag"? Because if I ctrl-c=>ctrl-v some phrase to tags field in my admin panel, on page with this tag i get something like this:

Reverse for 'posts_by_tag' with arguments '()' and keyword arguments '{u'tag':
u'\u0411\u0430\u043d\u043a \u0422\u0430\u0432\u0440\u0438\u043a\u0430'}'
not found. 1 pattern(s) tried: ['blog-list/posts/(?P<tag>\\w+)$']

, but if I try add tag with whitespace-it just cut on whitespace char and starts new tag. How can I fix it?

Upvotes: 0

Views: 428

Answers (2)

Patrick Bond
Patrick Bond

Reputation: 101

Here is an instruction on how to do it - link

  1. Create a file in the app folder "utils.py"

  2. Insert code

def comma_splitter(tag_string): return [t.strip().lower() for t in tag_string.split(',') if t.strip()]

  1. Insert a string into a file "settings.py"

TAGGIT_TAGS_FROM_STRING = 'appname.utils.comma_splitter'

Upvotes: 0

timo.rieber
timo.rieber

Reputation: 3867

Multi-word tags in Wagtail need to be quoted, e.g. "my tag".

There are two pull requests open that address this topic:

Upvotes: 1

Related Questions