Hi,
Try always not to think SQL and not to use extra. Most of the times there is
an alternative without extra. Extra is advanced.
class Node(Model):
widgets = ForeignKey(Widget)
This query will give you all the different nodes that have the foreign key
widgets set to something different
>From a raw SQL standpoint, I've figured out that these constraints
need to be in the HAVING clause, not the WHERE clause. But it looks
like HAVING is not exposed through the .extra() function, which would
seems logical. It appears you can create extra fields, but due to
this lack you can't
I have something like this:
class Node(Model):
widgets = ForeignKey(Widget)
And I want to retrieve all nodes that have >0 widgets. I have
an .extra() query like this:
nodes = Node.objects.all().extra(
select={
'num_widgets': 'SELECT COUNT(*) FROM
3 matches
Mail list logo