def get_intersection_by_ model self tags Create QuerySet containing in

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def get_intersection_by_model(self, tags):
"""
Create a ``QuerySet`` containing instances of the specified
model associated with *all* of the given list of tags.
"""
tags = get_tag_list(tags)
if not tags:
return self.model._default_manager.none()
objects_id = set([i.id for i in self.model._default_manager.all()])
for tag in tags:
objects_id = objects_id & set([i.object_id for i in TaggedItem.objects.filter(tag=tag)])
return self.model._default_manager.filter(pk__in=objects_id)