Suppose I've a JSONField namely "data" defined in one of my models.py in Django. The Contents of the field is somewhat similar to the following -
{
"name": "John",
"email": "johndoe@foo.bar",
"last name": "Doe"
}
I need to write a queries of the following form -
self.objects.filter(data__name="John")
How do I write a similar query for the key "last name". I'm not able to proceed since that key has a space. Was thinking of getting the data and filtering it using python, But I think there would be more efficient way to get it done.
I've not real control over the data in the JSONField. So, I can't really change the name of the key.