trouble finding the right django queryset for this
<p>I have two models like this:</p>

<pre><code>class Foo():
    name = CharField
    frequency = IntegerField

class Bar():
    thing = ForeignKey(Foo)
    content = TextField
</code></pre>

<p>I want to get a queryset that will be <code>Bar</code> objects sorted by a range of <code>Foo</code> objects. It obviously doesn't work, but it illustrates what I need.</p>

<pre><code>Foo.objects.order_by('-frequency')[0:10].bar_set.all()
</code></pre>

<p>if I am getting right what would you  like to achieve, try this:</p>

<pre><code>objs = Bar.objects.filter(thing__pk__in=Foo.objects.all().order_by('-frequency').values_list('pk', flat=True)[:10])
</code></pre>

python django