Django getting values from postgres JSON field

Viewed 1741

I have a simple model like:

class MyModel(models.Model):
    data = JSONField()

The JSONField data is in the following structure:

{
  "name": "Brian",
  "skills": [
     {"id": 4, "name": "First aid"},
     {"id": 5, "name": "Second aid"}
  ]
}

I'd like to create a query that gets a list of MyModels filtered by the id of the skill inside the data.

I've tried a few different avenues here, and can do the work in Python but I'm pretty sure there's a way to do this in Django; I think my SQL isn't good enough to figure it out.

Cheers in advance.

1 Answers
Related