django-taggit
django-taggit copied to clipboard
Use of `TAGGIT_CASE_INSENSITIVE` is misleading
As per the document, if we set this True, the developer could assume that the tags are case insensitive while querying.
https://github.com/alex/django-taggit/blob/089f6339c2975af1d32d11359b97a08a89b298f8/taggit/managers.py#L200
But the.get(name__iexact)
throws MultipleObjectsReturned
. Then I checked my data in db where I could find multiple entries of the same tag but in different case letters. I hope it is required to respect TAGGIT_CASE_INSENSITIVE
while creating the tag too? Or am I setting it wrong?
I do agree adding TAGGIT_CASE_INSENSITIVE
should limit all tags behaviour to be insensitive. Adding a new TAG, querying queries, etc but it seems it is not the current behaviour.
https://github.com/alex/django-taggit/blob/04c5a3823782b50674e04eee9ea6e63a4078eb0c/taggit/managers.py#L194-L199
TAGGIT_CASE_INSENSITIVE
comes into play when adding or settings tags. In either case, it takes the tag names you gave it, and does a case-insensitive lookup for each tag. If found, the found tag is used. If not found, a tag name is created with the input.
The problem is that when a new tag is created, it isn't coerced into lowercase. So, in TAGGIT_CASE_INSENSITIVE
mode, the first time a tag is created, it will determine the case for all future tags.
For example, I create a tag called pSyChoLoGy
and now I am forever cursed with this tag name on every future instance of it. When I write "psychology" or "Psychology" it's coerced into the disfigured version above.
Unless the end user has the ability to directly edit tags, they are forced to delete every single instance of this tag in order to get a second shot at writing it correctly the first time.
I think #98 may have been closed too soon.