The problem appears to be in the get_tag_list
utility function, which is called by get_by_model
. If passed a string (such as 'my tag with spaces'
), it will return the following query:
Tag.objects.filter(name__in=parse_tag_input(tags))
Unfortunately, the parse_tag_input
function assumes that space-separated words are different tags, so it will assert that you are searching for the tags ['my', 'tag', 'with', 'spaces']
, which will of course not return anything.
Later in the get_tag_list
function, there's a check to see if the input is a list/tuple:
elif isinstance(tags, (types.ListType, types.TupleType)):
...
The code following it does not call parse_tag_input (I guess it assumes that each string within the list/tuple is a fully-formed tag).
TL;DR: Thus, I believe that if you pass a tuple or a list containing the tag name, it will correctly find it.
TaggedItem.object.get_by_model(MyModel, ['my tag with spaces'])