Malcolm; Thanks for everything. I was hoping there was a trick here. I am interested in getting as much efficiency out of this as possible; in fact, it is queries like this that made me switch away from php due to sql hang ups. I guess the long lines of code will have to due. Thanks for the tip on when Django hits the db,
Thanks for all, Mn On May 29, 3:17 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2007-05-29 at 06:56 +0000, Michael Newman wrote: > > Thanks for the reply and sorry for my vagueness; > > > Rob: I was talking about really long lines of python. Thanks for the > > heads up about the all. I was just typing off the top of my head and > > still and figuring out python. > > > Malcom: I suppose that is what I am asking. Is there any simple way > > to take group of objects like breakingnews in my example and exclude > > those objects from another set of objects (news) without a for > > statement? > > No. The reasoning runs something like this: If you want to do something > in two queries like that, it's going to be because you want to filter > the intermediate results somehow. If you just want to extract the list > of ids that a straightforward list comprehension over the original > queryset, so it's not something we need to add extra support for. > > If you care about getting every last bit of efficiency out of your > queries, you won't be doing two queries anyway (we cannot possibly get > information from the first queryset without running the query, since the > language is called Python, not Psychic), so this construct isn't > relevant there. There is a variation on this problem where you might > need to build nested queries or some such, but there's no support for > that at the moment. One day, maybe, but not today. > > The "long lines" argument isn't really a problem, by the way. You can > happily write > > qs = Story.objects.exclude(....) > qs = qs.filter(....) > qs = qs.count() > > and no database queries will result. Querysets are only evaluated when > you access the results, not when you add constraints to them. So each > line need only contain one filter, if that's the way you wish to go. > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---