> Query sets are not executed on the database until you iterate, or > otherwise try to extract data from them. > > o = Recipe.objects > o2 = o.filter(xx) > o3 = o2.filter(yy) > o4 = o3.filter(zz) > > print o4 > > will result in just 1 query getting issued to the database - the final > query with three filters.
Thanks... I'm not sure but I don't think this is working I have... p = Product.objects if len(notsitelist)>=1: print "exluding sites: ", notsitelist p.exclude(fk_site__in=notsitelist) if len(cats)>=1: print "exluding categories: ", cats p.exclude(catalog__in=cats) p.order_by('?') return p.select_related()[:50] ... and funnily the order is the same every time (not random) and although the print statements are printing, it doesn't seem to be effecting the results. Is there way to do p.get_query(.)p.show_sql() ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---