'DJANGO JSON filtering nested value
I am trying to figure out how to filter out JSON in DJANGO when the structure looks like this:
some random ID is like random generate id like pad1g12312-421df-2131
"data": {
"steps":{
"some random ID":{
"name":"name1"
}
},
"process":{
"some random ID":{
"name":"PROCESS #1",
}
}
I am trying to figure out how to get the name under execution and operation
I tried follow with this post: Django JSONField filtering_
object.filter(data__steps__0__name='name1')
object.filter(data__process__0__name='PROCESS #1')
but it isn't working. I am assuming it's because the Random ID part doesn't work with the 0. Is there a way to do this?
Also, I would like to combine the two in the same filtering, like
object.filter(data__steps__0__name='name1' or data__process__0__name='PROCESS #1')
Is it possible to do that?
Thank you
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
