File: getting_started.rst

package info (click to toggle)
django-taggit 6.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,332 kB
  • sloc: python: 4,599; makefile: 45; sh: 15
file content (49 lines) | stat: -rw-r--r-- 1,661 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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_INSENSITIVE``

  When set to ``True``, tag lookups will be case insensitive. This defaults to ``False``.

* ``TAGGIT_STRIP_UNICODE_WHEN_SLUGIFYING``
  When this is set to ``True``, tag slugs will be limited to ASCII characters. In this case, if you also have ``unidecode`` installed,
  then tag sluggification will transform a tag like ``あい うえお`` to ``ai-ueo``.
  If you do not have ``unidecode`` installed, then you will usually be outright stripping unicode, meaning that something like ``helloあい`` will be slugified as ``hello``.

  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.