My Models looks like this
class Foo():
payload = JSONField()
Payload looks something like this
[{
"id": 12,
"names": [{"location": "New York"}, ]{"location": "Philly"}]
},
{
"id": 15,
"names": [{"location": "Paris"}, ]{"location": "Cannes"}]
}]
queryset = Foo.objects.all()
queryset = queryset.filter(payload__names__contains=[{"name": "Paris"}]) #this works!!
queryset = queryset.filter(payload__names__contains=[{"name": "Par"}]) #does not work
The second statement does not work - it returns 0 results. In the first case it works because the full text is provided. What is the best way to do this in rawSql? [I am assuming it is not possible in Django]
I went thorough this but cannot find what to use to do like
on a nested array json field.