On 3/7/06, Stephen Newey <[EMAIL PROTECTED] > wrote:

> At present, there isn't an 'exists' operation for queries - although it
> sounds like a good addition. It would probably end up as part of aggregate
> functionality, so it might be worth adding a note to ticket 1435 so your
> idea doesn't get forgotten.

I think I'm that much of a noob that I'm not too sure what idea it is
I've had! So if it's a good idea perhaps you could add it to the
ticket or explain it to me? :)

Ok - I'll add a note ot the ticket. FYI, its all to do with what Django does/should do when you are querying over a related object when multiple objects match (e.g., topic has only 1 parent, but a parent can have many topics). If you only have a single related object, 'equals' makes perfect sense (does the field on the related object equal...), but when there can be 0..n related objects, field like 'equals' don't make as much sense - it makes more sense to have other query types, like the 'sum' of a field over all related objects, or the 'average' of a field. In SQL terms, these are aggregate clauses, and are currently missing from Django. Simple existence check ('is there a related object?') is another candidate for this group of functions.

> However, in the interim, something like:

Thanks a lot for that, worked perfectly with a slight modification to
the syntax:
Topic.objects.filter(article__id__isnull=False).distinct()

Oops. Sorry - you were a victim of a pre-coffee morning suggestion. Luckily, you managed to work out the nugget of goodness from my caffeine deprive haze... :-)
 
Russ Magee %-)


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to