1-я:
class Item(models.Model):
title = models.TextField(blank=False)
date = models.DateTimeField(auto_now_add=True)
class TaggedItem(models.Model):
"""
Holds the relationship between a tag and the item being tagged.
"""
tag = models.ForeignKey(Tag, verbose_name=_('tag'), related_name='items')
content_type = models.ForeignKey(ContentType, verbose_name=_('content type'))
object_id = models.PositiveIntegerField(_('object id'), db_index=True)
object = generic.GenericForeignKey('content_type', 'object_id')
т.е на sql это выглядело бы !примерно так:
select distinct i.id from Item i
left join TaggedItem t on (t.object_id = i.id and t.content_type = x)
where t.tag_id in (1,2..N) order by i.created limit start,len