[Answered ]-Django get Foreignkey Reverse Model Queryset

2👍

You use the related name functionality.

articles = Reporter.objects.get(name='somename').article_set.all()

If you already have the reporter, this is even easier:

articles = my_reporter.article_set.all()

0👍

You have to write code like this;

 reporter_ids = Reporter.objects.filter(name='somename').values_list('id', flat=True)
 article = Article.objects.filter(reporter_id__in=reporter_ids)

Leave a comment