Commit 8c443c45 by Alex Gaynor

Added a generic view

parent 1059ed51
from django.contrib.contenttypes.models import ContentType
from django.shortcuts import get_object_or_404
from django.views.generic.object_detail import object_list
from taggit.models import TaggedItem, Tag
def tagged_object_list(request, slug, queryset, **kwargs):
if callable(queryset):
queryset = queryset()
tag = get_object_or_404(Tag, slug=slug)
qs = queryset.filter(pk__in=TaggedItem.objects.filter(
tag=tag, content_type=ContentType.objects.get_for_model(queryset.model)
)
return object_list(request, queryset, **kwargs)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment