openpolis/open_municipio — Issue #31: Use a model-specific tag model instead of a generic one
Author: seldon
Created: 2012-03-07 16:58:53+00:00
State: open
Labels: enhancement, taxonomy

Currently, our *tag model* is *generic* (i.e., it allows tagging of arbitrary model instances). Although this approach has obvious advantages (flexibility, DRYness, etc.), the fact that the implementation relies on `GenericForeignKeys` entails a few problems, notably that we cannot leverage [Django aggregation API](https://docs.djangoproject.com/en/1.3/topics/db/aggregation/), since it [doesn't work](https://docs.djangoproject.com/en/1.3/ref/contrib/contenttypes/#generic-relations-and-aggregation) with generic relations.

So, since:
1) we need to write aggregation-like queries involving tags
2) currently, only `Act` instances are taggable

a better choice would be to adopt a model-specific tag model.

Luckily, `django-taggit` supports [model-specific tagging](http://django-taggit.readthedocs.org/en/latest/custom_tagging.html) out-of-the-box.