Re: Reduce number of calls to database

2015-06-05 Thread Cherie Pun
Thanks! On Friday, 5 June 2015 08:53:48 UTC+1, kel...@ist-total.org wrote: > > On Fri Jun 5 08:32:52 2015 GMT+0100, Cherie Pun wrote: > > > > Thanks! Would this still give 404 errors when a certain object does not > > exist? > > Nope, but if you really need to ensure all ids exist in the datab

Re: Reduce number of calls to database

2015-06-05 Thread kelvan
On Fri Jun 5 08:32:52 2015 GMT+0100, Cherie Pun wrote: > > Thanks! Would this still give 404 errors when a certain object does not > exist? Nope, but if you really need to ensure all ids exist in the database, compare the length of your level_ids with levels.count() Make sure there are no dupli

Re: Reduce number of calls to database

2015-06-05 Thread Cherie Pun
Thanks! Would this still give 404 errors when a certain object does not exist? On Tuesday, 2 June 2015 17:07:49 UTC+1, Simon Charette wrote: > > Hi Cherie, > > A `id__in` queryset lookup should issue a single query. > > levels = Level.objects.filter(id__in=level_ids) > > Cheers, > Simon > > Le m

Re: Reduce number of calls to database

2015-06-02 Thread Simon Charette
Hi Cherie, A `id__in` queryset lookup should issue a single query. levels = Level.objects.filter(id__in=level_ids) Cheers, Simon Le mardi 2 juin 2015 11:42:19 UTC-4, Cherie Pun a écrit : > > Hi, > > I am new to Django and I am performing some iteration on a queryset. When > I use django_debug_

Reduce number of calls to database

2015-06-02 Thread Cherie Pun
Hi, I am new to Django and I am performing some iteration on a queryset. When I use django_debug_toolbar to look at the SQL usage, I realised that Django is actually calling the database once in each iteration. Is there a way to make it call the database only once and somehow store it locally s