[Answered ]-Django how to search for one Model based on multiple foreign keys?

1👍

I think maybe if you give a related_name to the ForeignKey, you should be able to search from Foo using that as the field.

So if you do models.ForeignKey(Foo, related_name="backlink"), then Foo would have a backlink field you could search on.

Have a look here and see if that helps.

https://docs.djangoproject.com/en/4.0/ref/models/fields/#django.db.models.ForeignKey.related_name

Leave a comment