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
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
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
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
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
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
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
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 =
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)
9 matches
Mail list logo