This is pretty easy to do with django-taggit. Subclass TagBase and force string restrictions in the save method. The rest is the boiler point, so the TaggableManager can use your subclass.
class LowerCaseTag(TagBase): def save(self, *args, **kwargs): self.name = self.name.lower() super(LowerCaseTag, self).save(*args, **kwargs) class LowerCaseTaggedItem(GenericTaggedItemBase): tag = models.ForeignKey(LowerCaseTag, related_name="tagged_items") class YourModel(models.Model): tags = TaggableManager(through=LowerCaseTaggedItem)
You can also set a range limit for tag numbers in the save method.
source share