Hi!
Regarding the .values() problem with JSON fields, has anyone as of yet thought about how escaping of attribute names in JSON fields is supposed to work?
We are using a JSON field to store user-defined extension fields. So say the user wants a "foo" text field. Then we'd store:
o.data = {}
o.data['foo'] = "Some text"
Then later, we can do SomeModel.objects.filter(data__foo__icontains="some") or SomeModel.objects.values_list('data__foo').
But in reality, since this is user defined, 'foo' above comes from a variable so the filter() has to be done with **{'data__' + field_name + '__icontains': "some"}. And then what happens when the user wants a field called "Foo the Bar"? Or "__init__"?
I haven't found a way to escape the field names in the documentation. Perhaps I'm not looking in the right place? It seems to me that we need something like JSONPath('data__', field_name) that hooks into the JSONField infrastructure.
Just to be clear, we have this in production in a fairly large system, and solved the escape problem by constraining the field names from containing __ and some other things. But not spaces, so were bitten by the new runtime check on .values().
Ole