dlamotte / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

tagged_object_list generic view and related_tags=True fails #179

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The generic view in tagging.views.tagged_object_list fails for me when passing 
a QuerySet 
instead of a Model and using related_tags=True.

Throws the following exception:
AttributeError at /tag/django/
'QuerySet' object has no attribute '_meta'

My view is such:

def tag_view(request, tag):
    queryset = BlogEntry.objects.all()
    return tagged_object_list(request, queryset, tag, paginate_by=25,
                  related_tags=True)

The alternative view using a model class, however, will work:

def tag_view(request, tag):
    return tagged_object_list(request, BlogEntry, tag, paginate_by=25,
                  related_tags=True)

The problem is in tagging.models, line 211, related_for_model:
            'content_type_id': ContentType.objects.get_for_model(model).pk,

related_for_model expects a Django model class, not a queryset, but the generic 
view specifies 
that you can pass either one. A Queryset object forces the call to 
ContentType.get_for_model to 
fail.

Original issue reported on code.google.com by jesse.l...@gmail.com on 3 Jan 2009 at 5:24