jazzband / django-taggit

Simple tagging for django
https://django-taggit.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.32k stars 622 forks source link

Missing tag validation in TaggitSerializer and TagListSerializerField #919

Open bluesurfer opened 1 month ago

bluesurfer commented 1 month ago

When using TaggitSerializer with TagListSerializerField tags value is not parsed.

I was expecting the same behavior of TagField in forms:

def clean(self, value):
    value = super().clean(value)
    try:
        return parse_tags(value)
    except ValueError:
        raise forms.ValidationError(
            _("Please provide a comma-separated list of tags.")
        )
rtpg commented 9 hours ago

@bluesurfer here, were you expecting to be able to pass something like "tag_a, tag_b, tag_c" into the serializer? You can already pass in ["tag_a", "tag_b", "tag_c"] and (for backwards compat reasons) "['tag_a', 'tag_b', 'tag_c']".

Forms have their own requirements, but for a REST API it seems a bit odd to be able to pass a comma separated string when you could likely just as easily pass in a list of strings. But I might be lacking imagination on the use case