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 Step by Step

Make Migrations on the newer version of Django

Just in case anyone else is following along on their local machine and is using a newer version of Django, you will probably get an error when you try and run the migrations suggesting that the Foreign Key requires an additional argument.

Changing the line to:

course = models.ForeignKey(Course, on_delete=models.CASCADE)

Should fix the issue.

Worked! Thanks for sharing, Marc!

Thanks Marc Busby I thought was doing something wrong. This should be included in the Teacher's note.

Thanks a lot! you saved me!

Thanks Marc! :)

This seems to work, too. Does anyone know the difference?

course = models.ForeignKey(Course, on_delete=models.DO_NOTHING)

@Anna Muravyeva the difference is that if you set models.CASCADE, Django will delete every Step entry related to specified Course if that course gets deleted. In contrast models.SET_NULL will... well, sets the course field to null.

There's more in the Django documentation

Thanks ;)

much appreciated!