On Mon, Jul 27, 2009 at 4:04 AM, Tom wrote:
>
> Hi,
>
> Thanks for the tip...
>
> But I've got a similar problem that needs the data from the linked
> model:
>
> (simple example)
>
> for school in SCHOOL.objects.all():
> print school.student.name
>
> When I run this in Django
Hi,
Thanks for the tip...
But I've got a similar problem that needs the data from the linked
model:
(simple example)
for school in SCHOOL.objects.all():
print school.student.name
When I run this in Django it makes a separate SQL call every time it
tries to get school.student.name.
It
Found the answer to my question just after posting...
for item in FOO.objects.select_related('bar'):
print item.bar.id
On Jul 19, 11:33 pm, Alex Gaynor wrote:
> On Sun, Jul 19, 2009 at 10:48 AM, aXqd wrote:
>
> > Hi, all:
>
> > Recently, I linked two
在 2009-7-20,0:33,Alex Gaynor 写到:
>
> On Sun, Jul 19, 2009 at 10:48 AM, aXqd wrote:
>>
>> Hi, all:
>>
>> Recently, I linked two models ( FOO & BAR ) with a foreign key.
>> Then I retrieved the whole records back with the following codes:
>>
>> 1 for item
On Sun, Jul 19, 2009 at 10:48 AM, aXqd wrote:
>
> Hi, all:
>
> Recently, I linked two models ( FOO & BAR ) with a foreign key.
> Then I retrieved the whole records back with the following codes:
>
> 1 for item in FOO.objects.all():
> 2 print item.bar.id
>
> In my opinion, the
Hi, all:
Recently, I linked two models ( FOO & BAR ) with a foreign key.
Then I retrieved the whole records back with the following codes:
1 for item in FOO.objects.all():
2 print item.bar.id
In my opinion, the whole thing should be lazy enough.
So if Line 1 got all the BAR id back, *WHY*
6 matches
Mail list logo