Django use F() to the jsonField and there is json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

26 Views Asked by At

this is the code

class Helo(models.Model):
    id = models.IntegerField(primary_key=True)
    aa = models.JSONField(null=True)
    bb = models.JSONField(null=True)

one example data is this:

id aa bb
1 {"p1":11 "p2": 22} {"p1": 33, "p2": 44}

and i run this code

test=Helo.filter(aa__p1__gte = F('bb__p1'))
test.count()

get these error message

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

i also tried the

test=Helo.filter(aa__p1__gte = F('bb'))
test.count()

and there is no error, i wonder why i cant use the

F('bb__p1')

0

There are 0 best solutions below