id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 9997,Nested queries support: Field for ValuesListQuerySet (flat=True) gets lost in query construction,Matthias Kestenholz,Malcolm Tredinnick,"I have a model called Favorite which has a generic foreign key. I want to get all bookmarked jobs for a user efficiently, therefore I query the database for all object_ids: {{{ ids = Favorite.objects.get_favorites_by_model(Job).filter(user=1).values_list('object_id', flat=True) In [28]: ids Out[28]: [338L, 308L, 212L, 345L, 307L, 264L, 322L, 354L, 326L, 328L, 335L, 334L, 332L, 353L, 352L, 351L, 350L, 349L, 316L] In [33]: type(ids) Out[33]: }}} Now, using this information I want to get a list of all jobs. However, the following two statements yield completely different results. Only the former is correct: {{{ In [22]: Job.objects.filter(id__in=tuple(ids)) Out[22]: [