Hello again DjangoUsers,
Thank you for your reply Malcolm, actually my problem remained in the
fact my own object name was not "Restaurant" but something like
"ItalianRestaurant", and I only tried to call it from places by
"italianRestaurant", as I would have done in Java reflect for example,
I didn't notice it has to be full lowercase like "italianrestaurant"
to work.
So this works as intended, but it hasn't changed the fact that around
2 thousands connexions are needed to do the request, instead of one.
I do the following :
for place in Place.objects.select_related() :
try :
restaurant = place.restaurant
except ObjectDoesNotExist :
pass
I got the same number of connexions when trying :
for place in Place.objects.all() :
try :
restaurant = place.restaurant
except ObjectDoesNotExist :
pass
Why does it hit the database when I write "select_related()" ?
Postgres logs tell me it hits the database each time I call
"place.restaurant", whether I'd written "select_related" or not.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---