Re: How do I filter/exclude custom queryset fields created by .extra()?

2010-10-29 Thread Miguel Araujo
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

Re: How do I filter/exclude custom queryset fields created by .extra()?

2010-10-29 Thread Jumpfroggy
>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

How do I filter/exclude custom queryset fields created by .extra()?

2010-10-28 Thread Jumpfroggy
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