Django Aggregate
Preparing data We’ll use the Employee and Department models from the hr application for the demonstration. The Employee and Department models map to the hr_employee and hr_department tables: First, add the salary field to the Employee model: class Employee(models.Model): salary = models.DecimalField(max_digits=15, decimal_places=2) # …Code language: Python (python) Second, make migrations using the makemigrations command: python manage.py makemigrationsCode language: Python (python) Output: Migrations for ‘hr’: hr\migrations\0005_employee_salary.py – Add field salary to employeeCodeContinue Reading