I'm using Django 3.2.3 / Python 3.7.8 / PostgreSQL 12.3
models.py
class Booking(models.Model):
reference = models.CharField(max_length=15, unique=True)
services = models.JSONField()
The services
structure is:
{
'1':{
'id': 3,
'name': 'Name 1'
},
'2':{
'id': 4,
'name': 'Name 2
},
'3':{
'id': 3,
'name': 'Name 3
},
...
}
How to filter the Booking
with services
having id
3
?
I tried Booking.objects.filter(services__contains=[{'id': 3}])
but couldn't get through.
Kindly help.