I solved a similar issue using custom SQL. It's a little tedious to write, but the boost is significant.
The way I've structured this: 1. create a manager for the main class 2. for each related object (either foreignKey or many2many), create a method fieldname_in_bulk() 3. create a method select_related_ex(), which uses the results of 2. More concretely: 2. fetches all related objects (irrespective of the object(s) to which it is attached) 3. associates objects and their related objects If your DB and model won't change too often, you can write pretty clear and concise SQL/SQL processing code. JJ. On Nov 26, 11:56 am, lispingng <[EMAIL PROTECTED]> wrote: > Hi, > I am working on a large project that requires i export applications to > csv. > the problem is the Application model has about six foreignkey fields > including one to the Profiles model. also there are two backward > relations to the Application models as well > in other words the model structure is a little complex. > now i want to export the data (its a school management app) with their > relationships > > class Application(models.Model): > profile = models.ForeignKey(Profiles, editable=False) > ... > ... > class School(models.Model): > '''the schools attended by the applicant''' > application = models.ForeignKey(Application) > > class WorkExperience(models.Model): > '''the jobs doen by the applicant''' > application = models.ForeignKey(Application) > > and so on. > right now i am looking for an alternative to picking each Aplication > object, one by one, and using select_related() to get related data > also thought about using custom sql but am not sure it is the right > thing to do...(maybe i'm just being lazy) > Any thoughts on how i can get around this? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---