I have a Q&A type of site built in Django with the following models:
class Question(models.Model):
title = models.CharField(max_length=70)
detail
#Consider A Foreign Key Relationship Between Books And Publisher
class Publisher(models.Model):
name = models.CharField(max_length=100)
eclass Book(models.Model):
publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)
#Fetch Publisher Name For A Book
book = Book.objects.select_related('publisher').get(id=1)
book.publisher.name
#Fetch books which have specific publisher
publisher = Publisher.objects.prefetch_related('book_set').get(id=1)
books = publisher.book_set.all()
for more https://kwikl3arn.com/django/JOINS