Saturday, October 2, 2021

Re: List Index out of Range

Which line in your code is triggering the error?

On Saturday, October 2, 2021 at 11:07:13 AM UTC-4 eugenet...@gmail.com wrote:
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")



image.png

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/8d69a634-0a2d-42e3-994c-5e19f88a799en%40googlegroups.com.

No comments:

Post a Comment