O'Reilly logo

Django By Example by Antonio Melé

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding tagging functionality

After implementing our comment system, we are going to create a way to tag our posts. We are going to do this by integrating a third-party Django tagging application in our project. django-taggit is a reusable application that primarily offers you a Tag model and a manager to easily add tags to any model. You can take a look at its source code at https://github.com/alex/django-taggit.

First, you need to install django-taggit via pip, running the following command:

pip install django-taggit==0.17.1

Then open the settings.py file of the mysite project and add taggit to your INSTALLED_APPS setting like this:

INSTALLED_APPS = (
    # ...
    'blog',
    'taggit',
)

Open the models.py file of your blog application and add the TaggableManager ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required