Django's ORM models the three fundamental database relationships with dedicated field types: ForeignKey (one-to-many), ManyToManyField (many-to-many), and OneToOneField (one-to-one). These define how tables relate and give you Pythonic access to related objects.
ForeignKey — one-to-many (the most common)
(models.Model):
name = models.CharField(max_length=)
(models.Model):
title = models.CharField(max_length=)
author = models.ForeignKey(
Author,
on_delete=models.CASCADE,
related_name=,
)
