'Validate the tags ensuring we have no case-sensitive duplicates.'

def clean_tags(self):

    tags = self.cleaned_data['tags']
    cleaned_tags = []
    if tags:
        for tag in parse_tags(tags):
            doc_tag = DocumentTag.objects.filter(name__exact=tag).values_list('name', flat=True)
            if (len(doc_tag) > 1):
                log.warn(('Found    duplicate    document    tags:    %s' % doc_tag))
            if doc_tag:
                if ((doc_tag[0] != tag) and (doc_tag[0].lower() == tag.lower())):
                    cleaned_tags.append(doc_tag[0])
                    continue
            cleaned_tags.append(tag)
    return '    '.join([(u'"%s"' % t) for t in cleaned_tags])
