how to access child models using parent models in django code example
Example: how to get parent model object based on child model filter in django
#Model
class Kid(models.Model):
name = models.CharField(max_length=200)
class Toy(models.Model):
name = models.CharField(max_length=200)
owner = models.ForeignKey(Kid)
#view
Kid.objects.distinct().filter(toy__name__icontains='star')