Operationalerror (1054, "unknown Column 'month' In 'field List'")
I'm annotating price per month from my database, and I'm facing this error, I'm trying to figure out why, so in my model I have a DateTimeField, I have tried playing with data insi
Solution 1:
I don't think you can use fields from extra
in a values
clause.
But this is really the wrong way to do it. You should be using Django's database function support; specifically, the extract
function:
from django.db.models.functions import Extract
Project.objects.annotate(month=Extract('created', 'month').values("month").annotate(sum_price=Sum("price_aux"))
Post a Comment for "Operationalerror (1054, "unknown Column 'month' In 'field List'")"