Re: How to reduce DB queries?

2011-03-02 Thread galago
That's nice. I must check it. -- 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 django-users+unsubscr...@googlegroups.com. For more

Re: How to reduce DB queries?

2011-03-01 Thread Tomasz Zieliński
On 27 Lut, 16:26, galago wrote: > In template in main loop I want to display all technologies assigned to the > each site. Technologies are assigned by m2m relation. So I run subloop as > You can see in code above. I want to reduce the number of queries executed > by those

Re: How to reduce DB queries?

2011-02-27 Thread Doug Ballance
Could you do a ManyToMany relationship through an intermediary model, and then query the intermediary using select related? -- 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

Re: How to reduce DB queries?

2011-02-27 Thread s . apostolico
Artur is right, I did not see that you use m2m. S. 2011/2/27 galago : > In template in main loop I want to display all technologies assigned to the > each site. Technologies are assigned by m2m relation. So I run subloop as > You can see in code above. I want to reduce the

Re: How to reduce DB queries?

2011-02-27 Thread Artur Wdowiarski
Actually, select_related won't help You with m2m fields. As it's written in docs linked by s.apostolico, it only works with ForeignKeys... As far as I know, there's no way to avoid the extra query using django's orm. 2011/2/27 galago > In template in main loop I want to

Re: How to reduce DB queries?

2011-02-27 Thread galago
In template in main loop I want to display all technologies assigned to the each site. Technologies are assigned by m2m relation. So I run subloop as You can see in code above. I want to reduce the number of queries executed by those subqueries. I want to know, if there is a better way to do

Re: How to reduce DB queries?

2011-02-27 Thread galago
I use select_related(). How to apply it with regroup? I haven't use it before. -- 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

Re: How to reduce DB queries?

2011-02-27 Thread s . apostolico
Take a look to : http://docs.djangoproject.com/en/1.2/ref/models/querysets/#select-related and http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#regroup Stefano 2011/2/27 galago : > Models: > class Technology(models.Model): >     name =

How to reduce DB queries?

2011-02-27 Thread galago
Models: class Technology(models.Model): name = models.CharField(max_length=100, unique=True) slug = models.SlugField(max_length=100, unique=True) class Site(models.Model): name = models.CharField(max_length=100, unique=True) slug = models.SlugField(max_length=100, unique=True)