I tried to sum the data from my database using below code.
models.py
class Income(models.Model):
Total= models.CharField(max_length=512,null =True,blank=True)
views.py :
Total_income = Income.objects.filter(Q(title='Salary')| Q(title='Bonus')).aggregate(Sum('Total'))
But I got this error when I try to run it.
('42000', '[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Operand data type nvarchar is invalid for sum operator. (8117) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)')
I'm new to Python and Django so I really appreciate your help on this.