#NEWLINE# def tagged_object_list( request , queryset_or_model = None , tag = None , related_tags = False , related_tag_counts = True , **kwargs ) : #NEWLINE# #INDENT# '\n    A thin wrapper around\n    ``django.views.generic.list_detail.object_list`` which creates a\n    ``QuerySet`` containing instances of the given queryset or model\n    tagged with the given tag.\n\n    In addition to the context variables set up by ``object_list``, a\n    ``tag`` context variable will contain the ``Tag`` instance for the\n    tag.\n\n    If ``related_tags`` is ``True``, a ``related_tags`` context variable\n    will contain tags related to the given tag for the given model.\n    Additionally, if ``related_tag_counts`` is ``True``, each related\n    tag will have a ``count`` attribute indicating the number of items\n    which have it in addition to the given tag.\n    ' #NEWLINE# if ( queryset_or_model is None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# queryset_or_model = kwargs . pop ( 'queryset_or_model' ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise AttributeError ( _ ( 'tagged_object_list must be called with a queryset or a model.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( tag is None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# tag = kwargs . pop ( 'tag' ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise AttributeError ( _ ( 'tagged_object_list must be called with a tag.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# tag_instance = get_tag ( tag ) #NEWLINE# if ( tag_instance is None ) : #NEWLINE# #INDENT# raise Http404 ( ( _ ( 'No Tag found matching "%s".' ) % tag ) ) #NEWLINE# #UNINDENT# queryset = TaggedItem . objects . get_by_model ( queryset_or_model , tag_instance ) #NEWLINE# if ( 'extra_context' not in kwargs ) : #NEWLINE# #INDENT# kwargs [ 'extra_context' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# kwargs [ 'extra_context' ] [ 'tag' ] = tag_instance #NEWLINE# if related_tags : #NEWLINE# #INDENT# kwargs [ 'extra_context' ] [ 'related_tags' ] = Tag . objects . related_for_model ( tag_instance , queryset_or_model , counts = related_tag_counts ) #NEWLINE# #UNINDENT# return object_list ( request , queryset , ** kwargs )