Saturday, October 2, 2021

List Index out of Range

Good day all,

I need assistance. Am trying to save data from the below form but I am getting list out of range error
 can someone help me to write a successful save function?

here is the code I am using:


def submit_work(request):
if request.method != "POST":
return HttpResponse("<h2>Method Not Allowed</h2>")
else:
pillar_id=request.POST.get("pillar")
object_id=request.POST.get("objects")
output_id=request.POST.get("output")
activity_id=request.POST.get("activity")
input_list=request.POST.getlist("input[]")
time_frame_list=request.POST.getlist("timeframe[]")
responsible_list=request.POST.getlist("responsible[]")
j=0
for inp in input_list:
wf=WORKFRAMS(pillar_id=pillar_id,object_id=object_id,output_id=output_id,activity_id=activity_id,
input=inp,time_frame=time_frame_list[j],responsible=responsible_list[j])
wf.save()
j=j+1
return HttpResponse("OK")





Regards, 

TUYIZERE Eugene


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABxpZHvXVqPzsFj3mq7Z0qHCSC-zMY_vuXAj8Hv%3Dxr2SMGu8Sw%40mail.gmail.com.

No comments:

Post a Comment