jinjie2088 / django-tagging

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

KeyError when using TaggedItem.objects.get_related(object, qs) #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When using the manager method TaggedItem.objects.get_related(object,
QuerySet) I get a KeyError as follows:

-------
    394             # clobber the ordering.
    395             object_dict = queryset.in_bulk(object_ids)
--> 396             return [object_dict[object_id] for object_id in object_ids]
    397         else:
    398             return []

KeyError: 1509566
-------

The problem doesn't occur if I pass the model rather than the queryset as
second parameter.

Any idea why this is happening?

Thanks and regards
Francesco

Original issue reported on code.google.com by fd.calab...@gmail.com on 2 Mar 2008 at 11:03

GoogleCodeExporter commented 9 years ago
If it can be of any help here is the traceback I get from django:
http://dpaste.com/37830/

Thanks

Original comment by fd.calab...@gmail.com on 3 Mar 2008 at 10:33

GoogleCodeExporter commented 9 years ago
IMHO problem occurs because object_ids gathered from entire model objects which 
has
more objects than queryset.
How about simple solution:

            object_dict = queryset.in_bulk(object_ids)
            return [object_dict[object_id] for object_id in object_ids if
object_dict.has_key(object_id)]
        else:
            return []

Original comment by n.le...@gmail.com on 10 May 2008 at 12:43

GoogleCodeExporter commented 9 years ago
Fixed in revision 136:

http://code.google.com/p/django-tagging/source/detail?r=136

Original comment by jonathan.buchanan on 10 May 2008 at 12:32