それぞれ4分かかるため、クエリを最適化する必要があります。これを実行したいのですが、有効かどうかはわかりません。fitting_listはクエリセットのリストでしたが、今では1つだけです
行き先:
company_list.append(Company.objects.filter(uuid__in=fitting_list.manufacturer.company.uuid).distinct())
address_list.append(Address.objects.filter(company__in=fitting_list.manufacturer.company.uuid).distinct())
customer_list.append(Customer.objects.filter(company__in=fitting_list.manufacturer.company.uuid).distinct())
manufacturer_list.append(Manufacturer.objects.filter(uuid__in=fitting.manufacturer.uuid).distinct())
から:
for fitting_queryset in fitting_list:
for fitting in fitting_queryset:
company_list.append(Company.objects.filter(uuid=fitting.manufacturer.company.uuid).distinct())
address_list.append(Address.objects.filter(company=fitting.manufacturer.company.uuid).distinct())
customer_list.append(Customer.objects.filter(company=fitting.manufacturer.company.uuid).distinct())
manufacturer_list.append(Manufacturer.objects.filter(uuid=fitting.manufacturer.uuid).distinct())