On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote: > > Hi, > > I have db-model like this: > > class Action(models.Model): > name = models.CharField(maxlength=64, unique=True) > photo = models.ForeignKey('Photo', null=True, blank=True) > > class Album(models.Model): > action = models.ForeignKey(Action, null=True, blank=True) > name = models.CharField(maxlength=64) > directory = models.CharField(maxlength=64, unique=True) > ... > def __str__(self): > if self.action: > return "%s - %s" % (self.action, self.name) > else: > return self.name > > > class Photo(models.Model): > album = models.ForeignKey(Album) > file_name = models.CharField(maxlength=64) > ... > def __str__(self): > return "%s/%s" % (self.album.directory, self.file_name) > > > When I go to admin page "Change action", then is executed 3597 SQL > queries and many of queries are same. > (database contains: 25 actions, 29 albums, 3592 photos) > > How to set model to automatic select related album when selecting a > photo?
http://www.djangoproject.com/documentation/model_api/#list-select-related > > or > how to set database result cache? > admin interface executes for each photo (in <select photo>) query > "SELECT * FROM album where id = ... " > > or another solution to reduce number of queries > > Thx. > > > > > -- Honza Kr�l E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420 606 678585 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---