ForeignKey and on_delete
Model one-to-many links and deletion behavior.
Linking Two Tables
Real data connects: a book has an author, an order has a customer. A ForeignKey is how one model points to another.
One-to-Many at a Glance
A ForeignKey models a one-to-many link. One author can have many books, but each book belongs to exactly one author.
All lessons in this course
- ForeignKey and on_delete
- ManyToManyField and Through Models
- OneToOneField for Profiles
- related_name and Reverse Lookups