Re: Django foreing keys joins

2013-06-09 Thread akaariai
On 6 kesä, 02:05, Àlex Pérez wrote: > Can someone tell me why the or in that query: > print Counter.on_medicos.filter(loc__isnull=True).only("id").query > > ""SELECT `web_counter`.`id` FROM `web_counter` LEFT OUTER JOIN > `locations_localidad` ON (`web_counter`.`loc` =

Re: Django foreing keys joins

2013-06-08 Thread Àlex Pérez
Thanks!, that query is making the join, and i wan't tho make a faster query, Joins ar not slow but if i can avoid it better. >>> print Counter.on_medicos.filter(loc_id__isnull=True).only('id').query My solution was: instead of put null values on empty relations, put a 0 value.. It work's very

Re: Django foreing keys joins

2013-06-06 Thread Jani Tiainen
That is how Django works. So as you see, django makes query where it compares _joined_ table id as a null. To make it happen (left outer) join must happen, otherwise it wouldn't return any rows. I agree that Django _could_ do a better and optimize query so that it would query instead of

Django foreing keys joins

2013-06-05 Thread Àlex Pérez
Can someone tell me why the or in that query: print Counter.on_medicos.filter(loc__isnull=True).only("id").query ""SELECT `web_counter`.`id` FROM `web_counter` LEFT OUTER JOIN `locations_localidad` ON (`web_counter`.`loc` = `locations_localidad`.`id`) WHERE (`web_counter`.`mode` = 1 AND