Django ManyToMany join query
Posted
by Hanpan
on Stack Overflow
See other posts from Stack Overflow
or by Hanpan
Published on 2010-03-18T22:53:22Z
Indexed on
2010/03/18
23:01 UTC
Read the original article
Hit count: 581
django
I'm sure this is really simple, but I can't for the life of me find any documentation explaining how to do this.
How do I get the results of a ManyToMany field inside a join as opposed to doing this:
{% for tag in article.tags.all %}
Which results in an extra query? What I'd like to do is fetch all related tags when I retrieve the initial article, so I could then do something like:
{% for tag in article.tags %}
Without the .all and the extra query.
Thanks!
© Stack Overflow or respective owner