Re: Using Q objects vs explicit filters

2011-04-14 Thread Gianluca Sforna
On Thu, Apr 14, 2011 at 11:46 AM, Massimiliano della Rovere wrote: > what about Parent.objects.filter(~q) ? In [16]: f1 = Parent.objects.filter(~q) In [17]: print f1.query SELECT "molserv_parent"."id", "molserv_parent"."name" FROM "molserv_parent" WHERE NOT ("molserv_parent"."id" IN (SELECT U1."

Re: Using Q objects vs explicit filters

2011-04-14 Thread Massimiliano della Rovere
what about Parent.objects.filter(~q) ? On Thu, Apr 14, 2011 at 11:08, Gianluca Sforna wrote: > On Wed, Apr 13, 2011 at 3:43 PM, Brian Bouterse wrote: >> Could you include the output to highlight the differences? > > I've just created a simpler test case. I've a couple models like: > > class Par

Re: Using Q objects vs explicit filters

2011-04-14 Thread Gianluca Sforna
On Wed, Apr 13, 2011 at 3:43 PM, Brian Bouterse wrote: > Could you include the output to highlight the differences? I've just created a simpler test case. I've a couple models like: class Parent(models.Model): name = models.CharField(max_length=200, db_index=True) class Child(models.Model):

Re: Using Q objects vs explicit filters

2011-04-13 Thread Brian Bouterse
Could you include the output to highlight the differences? Brian On Wed, Apr 13, 2011 at 9:32 AM, Gianluca Sforna wrote: > In writing a complex filter for an application, I've found a different > behavior between a filter like: > Model.objects.exclude(filter1, filter2) > > and one like: > Model

Using Q objects vs explicit filters

2011-04-13 Thread Gianluca Sforna
In writing a complex filter for an application, I've found a different behavior between a filter like: Model.objects.exclude(filter1, filter2) and one like: Model.objects.exclude(Q(filter1), Q(filter2)) where filter1 and filter2 are both field lookups on related models; in particular only the sec