Using a Custom Through Model
============================

By default ``django-taggit`` uses a "through model" with a
``GenericForeignKey`` on it.  However, there are some cases where this
isn't desirable, for example if you want the speed and referential
guarantees of a real ``ForeignKey``, or if you have a model with a
non-integer primary key.  In these cases ``django-taggit`` makes it
easy to substitute your own through model.

Youe intermediary model must be a subclass of
``taggit.models.TaggedItemBase`` with a foreign key to your content
model named ``content_object``. Pass this intermediary model as the
``through`` argument to ``TaggableManager``::

    from django.db import models

    from taggit.managers import TaggableManager
    from taggit.models import TaggedItemBase

    
    class TaggedFood(TaggedItemBase):
        content_object = models.ForeignKey('Food')
    
    class Food(models.Model):
        # ... fields here

        tags = TaggableManager(through=TaggedFood)


Once this is done, the API works the same as for GFK-tagged models.
