Getting Started¶
To get started using django-taggit simply install it with
pip:
$ pip install django-taggit
Add "taggit" to your project’s INSTALLED_APPS setting.
Run ./manage.py migrate.
And then to any model you want tagging on do the following:
from django.db import models
from taggit.managers import TaggableManager
class Food(models.Model):
# ... fields here
tags = TaggableManager()
Note
If you want django-taggit to be CASE-INSENSITIVE when looking up existing tags, you’ll have to set TAGGIT_CASE_INSENSITIVE (in settings.py or wherever you have your Django settings) to True (False by default):
TAGGIT_CASE_INSENSITIVE = True
Settings¶
The following Django-level settings affect the behavior of the library
TAGGIT_CASE_INSENSITIVEWhen set to
True, tag lookups will be case insensitive. This defaults toFalse.TAGGIT_STRIP_UNICODE_WHEN_SLUGIFYINGWhen this is set toTrue, tag slugs will be limited to ASCII characters. In this case, if you also haveunidecodeinstalled, then tag sluggification will transform a tag likeあい うえおtoai-ueo. If you do not haveunidecodeinstalled, then you will usually be outright stripping unicode, meaning that something likehelloあいwill be slugified ashello.This value defaults to
False, meaning that unicode is preserved in slugification.Because the behavior when
Trueis set leads to situations where slugs can be entirely stripped to an empty string, we recommend not activating this.