Skip to content

Instantly share code, notes, and snippets.

@pagles
Created June 3, 2011 06:34
Show Gist options
  • Save pagles/1005962 to your computer and use it in GitHub Desktop.
Save pagles/1005962 to your computer and use it in GitHub Desktop.
Using django taggit with custom tags
class MyTag(TagBase):
def slugify(self, tag, i=None):
slug = slughifi(tag)
if i is not None:
slug += "_%d" % i
return slug
class Meta:
verbose_name = _("Tag")
verbose_name_plural = _("Tags")
class MyTagItem(GenericTaggedItemBase):
tag = models.ForeignKey(MyTag, related_name="items")
# Then in your models
tags = TaggableManager(through=MyTagItem)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment