Is it even possible to filter a JsonField tuple or list? (Filtering only works for dictionaries?)

The documentation has info on querying JsonFields for dictionaries but not for lists or tuples.

# models.py
class Item(model):
    numbers = JSONField()

# tests.py
a = Item.objects.create(numbers=(1, 2, 3))
b = Item.objects.create(numbers=(4, 5, 6))

Item.objects.filter(numbers=a.numbers).count() # returns 0
Item.objects.filter(numbers__0=a.numbers[0]).count() # returns 0

Item.objects.all().count() # correctly returns 2
a.numbers # correctly returns (1, 2, 3)
a.numbers[0] # correctly returns 1

How can I query or filter by a JsonField if that field is a tuple or list?



from Recent Questions - Stack Overflow https://ift.tt/3vwiOut
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation