문제

Django Tag object has a default function add_tag(), it seems it only allow one word for the tag name, is there anyway to save a tag contains more than one words?

도움이 되었습니까?

해결책

If you are using django-tagging, you can add tags with spaces by either putting quotes around the tag or using commas to separate the tags. It makes sense in the context of adding multiple tags, but I think it works the same for individual tags too.

Note: The following code is untested

Tag.objects.add_tag(obj, '"banana split"')
Tag.objects.add_tag(obj, 'banana split,')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top