Hi :)
Thank you very much for aswering again Malcolm.

> The short answer is because select_related() does not work across
> reverse links (the Place -> Restaurant direction). It also won't save
> you any requests when model inheritance is implemented.

I think I've already read it somewhere, but I needed confirmation,
thanks.

> The longer answer is that if you know you want to work with the
> Restaurant objects, it is better to request them directly (and use
> select_related()), rather than requesting the least-specific object and
> trying to specialise.

You're right, but actually I do need to get all the Places, whether
they have Restaurants or not, that's why I can't do it that way.

> If you think about things in the model inheritance type of situation
> (which OneToOne emulates fairly well), this will make more sense: you
> could have many different tables links to the Place "parent" model. So
> if you are querying Place objects you apparently want to work with the
> lowest common denominator fields and only specialise on demand.
> Otherwise, we would need to query across a potentially very large number
> of tables (including all sub-sub-classes, etc) to get everything.

How about specializing tables like it can be done for fields with the
"values(*fields)" method ?
I mean there could be a "select_related(*tables)" method that allows
us to specify which table we want to retrieve the results from.

Of course, it is just an idea like any other, and I reckon Django devs
have something else to deal with for the moment =)


Just FYI, for my problem, I'm going to retrieve all the places and all
the restaurants, and then do my "LEFT JOIN" programmatically.
I know it is not a good way of development, but it is the only
workaround I thought about to limit the number of database requests.


BTW, thank you again Malcolm, I hope I'm not going to ask you anything
before longtime :)

Anthony.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to