0

I have a model MyModel that contains a JSONField named calculo in MySQL and I want to annotate the value of premio to perform aggregated sum. How can I make this work?

class MyModel(models.Model):
    ...
    calculo = JSONField(blank=True, null=True)
    ...

I have tried this but got an empty dict.

 qs = MyModel.annotate(value=F('calculo__premio'))

Fairfax field:

'{"sc_ha": 2.77, "premio": 27735.84, "status": "1"}'
Igor
  • 35
  • 9

0 Answers0