On Mon, May 24, 2010 at 3:36 PM, Tom Evans <tevans...@googlemail.com> wrote: > On Mon, May 24, 2010 at 3:23 PM, omat <o...@gezgin.com> wrote: >> ops, this doesn't work, because the the Quiz model is pointing to the >> User model, and i want to filter on the quiz model and get the >> matching User instances. but in the example in the docs, the query is >> on the parent model. >> >> quiz_qs = Quiz.objects.filter(score__gt=90) >> User.objects.filter(quiz__in=quiz_qs) >> >> is not possible as User does not have a quiz attribute. >> >> and daniel, yours, saying "user.id in Quiz queryset" does not look ok: >> User.objects.filter(id__in=Quiz.objects.filter(score__gt=90)) >> >> >> Still stuck. Any ideas? > > User.objets.filter(pk__in=Quiz.objects.filter(score__gt=90).values_list('id', > flat=True)) > doh!
User.objects.filter(pk__in=Quiz.objects.filter(score__gt=90).values_list('user_id', flat=True)) Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.