Hi Colin,
The problem is that there are multiple ForeignKeys in A bound to
instances of B, but I only want the instances of B bound to a specific
foreignkey. Does that make sense?
-Benjamin
On Aug 3, 12:17 am, Collin Grady <[EMAIL PROTECTED]> wrote:
> I feel silly for not trying this earlier,
On 8/3/07, Collin Grady <[EMAIL PROTECTED]> wrote:
> >>> B.objects.filter(a__isnull=False)
> [, ]
And as pointed out in our IRC discussion, that needs a distinct()
slapped on the end to weed out duplicate results ;)
--
"Bureaucrat Conrad, you are technically correct -- the best kind of
I feel silly for not trying this earlier, but it appears to work :)
>>> B.objects.filter(a__isnull=False)
[, ]
Models used for this test: http://dpaste.com/15931/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
On 8/3/07, James Bennett <[EMAIL PROTECTED]> wrote:
> Foo.objects.extra(where=['id IN (SELECT %s FROM %s)' % Bar._meta.db_table])
Should have been:
> Foo.objects.extra(where=['id IN (SELECT foo_id FROM %s)' %
> Bar._meta.db_table])
(sent before I realized I'd decided not to use quote_name()
On 8/3/07, Collin Grady <[EMAIL PROTECTED]> wrote:
> He wants every B that has an A fkeyed to it.
>
> In other words, every instance of B where b.a_set.count() > 0
In which case what he wants is probably something like
ModelB.objects.filter(id__in=[o.id for o in ModelA.objects.all()])
Which is
Neither of those is correct.
He wants every B that has an A fkeyed to it.
In other words, every instance of B where b.a_set.count() > 0
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To
In model B.. if you say
modela = models.ForeignKey(ModelA)
You could also say b.modela_set.all()
On Aug 2, 8:18 pm, Lucky B <[EMAIL PROTECTED]> wrote:
> If I gather correctly you want to see every ModelA that's bound to a
> particular ModelB b?
>
> ModelA.objects.filter(modelBs=b)
>
> That
If I gather correctly you want to see every ModelA that's bound to a
particular ModelB b?
ModelA.objects.filter(modelBs=b)
That gives you what you want.
On Aug 2, 7:20 pm, Benjamin Goldenberg <[EMAIL PROTECTED]> wrote:
> Hi everyone,
> I asked about this earlier today on IRC and no one knew of
Hi everyone,
I asked about this earlier today on IRC and no one knew of a way to do
it. Basically I have a model, let's call it ModelA with a ForeignKey
to an instance of ModelB. I would like QuerySet of all instances of
ModelB that are bound to that particular ForeignKey. Does anyone have
any
9 matches
Mail list logo