nanoman
0
Q:

get related values in dajngo template

#Model
class Forum(models.Model):
	...
class ForumFront(models.Model):
    forum = models.ForeignKey(Forum, default=None)
    post_count = models.IntegerField(default=0)
    topic_count = models.IntegerField(default=0)
    
#Template
{{ forum }}
<ul>
{% for x in forum.forumfront_set.all %}
    <li>{{ x.topic_count }}, {{ x.post_count }}</li>
{% endfor %}
</ul>
0

New to Communities?

Join the community