I am trying to render my models in a template but just one tiny thing shows more times than I expect. I just want category name to show one time for many lectures and if there no lectures I want the category not to show. I just cant figure where to modify the template code. One mention: all my courses use same categories.
` <ul>
{% for a in categories %}
<li><strong>{{ a.course_category }}</strong></li>
{% for c in lectures %}
{% if a == c.course_category %}
<li>{{ c.lecture_title }}</li>
<li>{{ c.content }}</li>
{% if c.link %}
<li>{{ c.link }}</li>
{% endif %}
{% if c.file %}
<li><a href='{{ MEDIA_URL }}{{ c.file.url }}'>download</a></li>
{% endif %}
{% endif %}
{% endfor %}
<hr/>
{% endfor %}
</ul>`