> filterList = accounts.objects.filter(name="foo", company="bar", blah blah blah..)
>
> itemsList = items.objects.filter(account__in=accountList, status="delivered", andSo="on"....)
>
>
Not sure if I understand it correctly, but shouldn't this work better?
items list=items.objects.filter(status="delivered",account__name="foo",account__company="bar",account__blah blah...)
If you want to separate where in the code you set the 'account' criteria from the 'items' ones, simply pass a dictionary with the arguments for the first .filter() and prep end 'account__' to all the keys before feeding to the items.objects.filter() call.
--
Javier
Hi,I have an application that needs to do a fairly big search across a large number of records that goes something like...
filterList = accounts.objects.filter(name="foo", company="bar", blah blah blah..)itemsList = items.objects.filter(account__in=accountList, status="delivered", andSo="on"....)
The problem that I would like to overcome is that the 'account__in=accountList' creates some very inefficient SQL and slow's this query down a lot.What I thought of doing instead was:
filterList = accounts.objects.filter(name="foo", company="bar", blah blah blah..)
for account in filterList:itemsList = items.objects.filter(account=account, status="delivered", andSo="on"....)# I know it's not possible to extend a django queryset, I'm looking for an equivalentwholeItemsList.extend(itemsList)Now I know the .extend method won't work on a django queryset, and I realise that it's possible to convert the queryset to a list and than extend them but that would use a horrible ammount of memory to duplicate the queryset in this instance and wouldn't give me much of a time advantage.What I would like to do is to add each of the querysets, searching for them without the '__in' filter saves a lot on sql, but then I don't want to loose the efficiency that would gain by adding another latency.Any Ideas would be greatly appreciated....Many thanks,Neil