<s> from __future__ import unicode_literals <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . shortcuts import get_object_or_404 <EOL> from django . views . generic . list import ListView <EOL> from taggit . models import Tag , TaggedItem <EOL> def tagged_object_list ( request , slug , queryset , ** kwargs ) : <EOL> if callable ( queryset ) : <EOL> queryset = queryset ( ) <EOL> tag = get_object_or_404 ( Tag , slug = slug ) <EOL> qs = queryset . filter ( pk__in = TaggedItem . objects . filter ( <EOL> tag = tag , content_type = ContentType . objects . get_for_model ( queryset . model ) <EOL> ) . values_list ( "<STR_LIT>" , flat = True ) ) <EOL> if "<STR_LIT>" not in kwargs : <EOL> kwargs [ "<STR_LIT>" ] = { } <EOL> kwargs [ "<STR_LIT>" ] [ "<STR_LIT>" ] = tag <EOL> return ListView . as_view ( request , qs , ** kwargs ) </s>
