N
N
Nikolai Vinogradov2016-08-24 15:38:19
Django
Nikolai Vinogradov, 2016-08-24 15:38:19

How to use tags with spaces in django-taggit?

Tags are screwed to the portal, they work well. But in the admin panel they are separated by a space. If I do ctrl-c=>ctrl-v in the tag field of a phrase with a space, I get

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+)$']

Is there a way to fix this and use space tags? Like "Simple tag" or "Complex tag".

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Vinogradov, 2016-08-24
@Kibastus

In general, it is advised in the world to use "" for multi-word tags. But be careful when writing a pattern in regexp for your url, so that there are no embarrassments, because although such a tag is considered to be a single line, in the url it must be given a pattern suitable for all the conditions of the tag (number of spaces, characters before and after it).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question