Duplicate tag objects (due to inconsistent lower/upper case) break the start page
Currently stadtgestalten.org suffers from the following exception when rendering the front page:
MultipleObjectsReturned at /
get() returned more than one Tag -- it returned 2!
It is caused by this line in grouprise.features.tags.markdown
:
tag = Tag.objects.get(name__iexact=name)
The following query shows all problematic tags:
from taggit.models import Tag
for t in Tag.objects.all():
matches = Tag.objects.filter(name__iexact=t.name)
if matches.count() > 1:
print(" ".join(match.name for match in matches))
For stadtgestalten.org this results in about 20 problematic tags.
We should probably clean up the existing content of the database? Ideally we should do this in the code, maybe as a migration?