'How can filter parent based on children in django

I have this

from django.db import models

class Kid(models.Model):
    name = models.CharField(max_length=200)

class Toy(models.Model):
    name = models.CharField(max_length=200)
    owner = models.ForeignKey(Kid)

I have this queryset

kids = Kid.objects.all()

Now I want to filter kids whole toys has name star in it

and I am not able to decide which filter to apply

kids.filter(toys_set__icontains='star')



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source