[Answered ]-Django model with multiple foreign keys

1👍

You can prefetch_related all backwards relationship and make an iteration similar to this:

areas = Area.objects.prefetch_related('need_area__category_need__products')

for area in areas:
    # iterate through each instance of Area
    for need in area.need_area.all():
        # iterate through  each instance of Need for the given area
        for product_category in need.category_need.all():
            # iterate through each instance of ProductCategory for the given need
            for product in product_category.products.all():
                # iterate through each instance of product for the given product category

Leave a comment