I'm using PostgreSQL and this new field from Django 1.9, JSONField. So I got the following data:
id|data
1 |[{'animal': 'cat', 'name': 'tom'}, {'animal': 'dog', 'name': 'jerry'}, {'animal': 'dog', 'name': 'garfield'}]
I'm trying to figure out how to filter in this list of json. I tried something like: object.filter(data__contains={'animal': 'cat'}
but I know this is not the way. Also I've been thinking in get this value and filter it in my code:
[x for x in data if x['animal'] == 'cat']
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…