-
Notifications
You must be signed in to change notification settings - Fork 23
Description
I'm playing with django-tagging-ng and I've written a view function to add new tags to an object
def add(request):
if request.method == 'POST':
form = TagForm(request.POST)
if form.is_valid():
model = models.get_model(request.GET.get('app_label'), request.GET.get('object_name'))
record = model.objects.get(id=request.GET.get('id', None))
tags = form.cleaned_data['tags']
Tag.objects.add_tag(record, tags)
referer = request.META.get('HTTP_REFERER', '/')
return HttpResponseRedirect(referer)
This is supposed to add a tag to an object. It works fine in the case that form.cleaned_data['tags'] contains a single tag.
I've also succeeded in adding multiple tags by iterating over parse_tag_input(form.cleaned_data['tags']) and adding a single tag in each iteration
BUT.. When the tag input is like '''one two "three four"''' I fail because parse_tag_input is treating "three four" as a single tag.
Inside add_tag it fails if a tag has multiple elements.
What is the most convenient way to append tags to a list of existing tags for an object and to handle inputs like ''' one two "three four"'''
Sorry if this isn't clear - it actually makes no sense as I read it back to myself :(