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
The following Django-level settings affect the behavior of the library
TAGGIT_CASE_INSENSITIVE
When set to
True
, tag lookups will be case insensitive. This defaults toFalse
.TAGGIT_STRIP_UNICODE_WHEN_SLUGIFYING
When this is set toTrue
, tag slugs will be limited to ASCII characters. In this case, if you also haveunidecode
installed, then tag sluggification will transform a tag likeあい うえお
toai-ueo
. If you do not haveunidecode
installed, 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
True
is set leads to situations where slugs can be entirely stripped to an empty string, we recommend not activating this.