[Answer]-Getting FK set from given QuerySet

1👍

Well you have answered your question:

Consider this, when create a Foreign Key reference then, Django automatically creates a reverse reference for you which is why you are able to filter results based on the child. Moreover, if you want to abide this behavior you can use Symmetrical=False kwargs in the Model Field to not generate the reverse relationship.

class Parent(models.Model):
...

class Child(models.Model):
     parent = models.ForeignKey(Parent)

You can always make the query:

Parent.objects.filter(child__in = Childrens.objects.all())

Leave a comment