0PricingLogin
Django Academy · Lesson

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

  1. ForeignKey and on_delete
  2. ManyToManyField and Through Models
  3. OneToOneField for Profiles
  4. related_name and Reverse Lookups
← Back to Django Academy