有两个列表:
master_values:
Order By
卡车对象:
[{<Truckdb: Truckdb object (141)>: [<ItemBatch: Iphone>, <ItemBatch: Iphone>, <ItemBatch: Iphone>, <ItemBatch: Iphone>]}, {<Truckdb: Truckdb object (18)>: [<ItemBatch: Iphone>]}]
当我运行以下代码时,它会产生比应有的调度计划更多的信息:
[<truck_name: 17 Feet 6000>, <truck_name: Tempo 407 1500>]
在此过程中,本应仅创建两个调度计划,却创建了五个调度计划
Models.py
for i in range(len(truck_objects)):
for j in range(len(master_values)):
if i == j:
for q, w in master_values[j].items():
for aa in range(len(w)):
print("len(w) ",len(w))
DispatchPlan.objects.create(owner=request.user,
truck_type=container_object,
truck_name=truck_objects[i],
items=w[aa])