Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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')
 
PREVIOUS NEXT
Tagged: #parent #model #object #based #child #model #filter #django
ADD COMMENT
Topic
Name
8+1 =