I have a model MyModel
with a JSONField
called data
. This json field contains an array of objects like:
[
{
"date": "2021-01-01",
"amount": 120
},
{
"date": "2021-01-02",
"amount": 150
}
]
I would like to filter by the amount
of the last element of the array. From the Django documentation, I understand that I can filter by the first element using:
MyModel.objects.filter(data__0__amount__gte=100)
How could I do this using the last element?