manytomany object for loop

이다연·2021년 3월 16일
0

Django

목록 보기
17/33

Nested for loop

Tags

{% for item in tutorials %}

	{% for tag in item.tags.all %}
	{{ tag }}
	{% endfor %}

{% endfor %}    
<h4>4 tutorial -> core.CurriculumItem.None / .all is the key </h4>

  {% for item in curriculum.tutorial.all %}
         {{ item.title }}
            <br>
        {{ item.instructor }}
            <br>
        {{ item.link }}
    {% endfor %}
{% for item in tutorials %}
                            <tr>
                                <td><button class="btn btn-warning search_btn" type="submit"> Add </button></td>
                                <td><a href="{% url 'hub:tutorial_detail' item.pk %}">{{item.title}}</a></td>
                                <td>{{item.instructor}}</td>
                                <td>
                                {% for tag in item.tags.all %}
                                {{ tag }}
                                {% endfor %}
                                </td>
                                <td>{{item.last_updated}}</td>
                                <td>{{item.difficulty}}</td>
                                <td>{{item.language}}</td>
                                <td>{{item.duration}}</td>
profile
Dayeon Lee | Django & Python Web Developer

0개의 댓글