On Tue, Jul 03, Johann C. Rocholl wrote: > > Often I want to preload just some foreign keys, not all of them as > select_related() does. Other people seem to need this feature too: > http://groups.google.com/group/django-developers/browse_thread/thread/e5e0de59e8304bcd/bb93410289bc19b7 > http://code.djangoproject.com/ticket/3275 > > My solution: I have written a function that preloads only the > requested foreign keys, and only for the objects that are already > selected. My implementation is available here: > http://trac.browsershots.org/browser/branches/shotserver-django/shotserver04/common/preload.py > > [...]
Your approach means that you need a first query to fetch the "first level" models, and then another query for each each of the foreign keys you want to follow. Well ... this is easy to implement and works around potential problems with outer joins, but I consider it cheating ;-) I'd like a proper solution to extend select_related(), and to need only a single query for fetching all data. Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" 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-developers?hl=en -~----------~----~----~----~------~----~------~--~---
