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 Final Details Step Detail View

Sahar Nasiri
Sahar Nasiri
7,454 Points

course_id

In this line of code:

step = get_object_or_404(Step, course_id=course_pk, pk=step_pk)

Is this course_id argument defined in Step module? Cause we know that get_object_or_404 function has know id about course_id!

Luc van Montfort
Luc van Montfort
6,242 Points

When you call models.ForeignKey() in your 'Step' model, behind the scenes django appends '_id' to the fieldname ('course' in this instance), thereby creating its column name in the 'Step' table. Every row (instance) in your 'Step' table will have a value in the 'course_id' column which corresponds to the id of the course the step belongs to.