skip to Main Content

Groupby using Django's ORM to get a dictionary of lists from the queryset of model with foreignkey – Postgresql

I have two models, Business and Employee: from django.db import models class Business(models.Model): name = models.CharField(max_length=150) # ... class Employee(models.Model): business = models.ForeignKey( Business, related_name="employees", on_delete=models.CASCADE, ) name = models.CharField(max_length=150) # ... Here's a sample data: Business.objects.create(name="first company") Business.objects.create(name="second company")…

VIEW QUESTION
Back To Top
Search