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.
widgets = ForeignKey(Widget)
This query will give you all the different nodes that have the foreign key widgets set to something different than null:
Node.objects.filter(widgets__isnull = False).distinct()
As your ForeignKey widgets can not be null, all nodes in the table will point to at least one widget. So it's the same as if you do:
Node.objects.all().distinct()
Maybe you want to do this:
class Node(Model):
widgets = ForeignKey(Widget, null=True)
widgets = ForeignKey(Widget, null=True)
Regards,
Miguel Araujo
2010/10/29 Jumpfroggy <rocketmonkeys@gmail.com>
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 filter on them. Is there another way to customize
the HAVING field?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment