Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics Django Templates Add a Detail View

Gilang Ilhami
Gilang Ilhami
12,045 Points

Nothin appeared during the {% for step in course.step_set.all %} loop

While the course's title and descriptions appeared, the step title and descriptions in the for loop did not appear.

{% extends "layout.html" %}

{% block title %}{{ course.title }}{% endblock title %}

{% block content %}
<article>
  <h2>{{ course.title }}</h2>
  {{ course.description }}

  <section>
    {% for step in course.step_set.all %}
      <h3>{{ step.title }}</h3>
      {{ step.description }}
    {% endfor %}
  </section>
</article>
{% endblock content %}

2 Answers

Kenneth is great teacher but if you really want to know whats happening under the hood then go trough official Django tutorial for begginers

link: https://docs.djangoproject.com/en/1.11/intro/tutorial01/

Haydar Al-Rikabi
Haydar Al-Rikabi
5,971 Points

Make sure that the "Step" model in your app's models.py has this foreign key: course = models.ForeignKey(Course)