Adding to above 2 answers index error may also occur when your
time_frame_list or responsible_list does not have the same number of items
as your input_list. You should try bnmng' s answer also
> Which line in your code is triggering the error?

you check it with simple print statements or using a debugger in vscode, or
with ipdb.set_trace()


On Sun, 3 Oct 2021 at 05:50, Hedrick Godson's <hedrickgod...@gmail.com>
wrote:

> Make sure you fill all the inputs with list and also make sure that you
> provide the correct input name to request.POST.getlist() method otherwise
> it will returns empty list which will raise IndexError
>
> On Sun, 3 Oct 2021, 03:13 bnmng, <benja...@bnmng.com> wrote:
>
>> 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: 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+unsubscr...@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
>> <https://groups.google.com/d/msgid/django-users/8d69a634-0a2d-42e3-994c-5e19f88a799en%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJAxQD%3Dw6GmZkS%2BPJs%2BJp21Z4Mn3pDS7XbxXp%2BBhLB1Rf3k7wg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJAxQD%3Dw6GmZkS%2BPJs%2BJp21Z4Mn3pDS7XbxXp%2BBhLB1Rf3k7wg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVEecPWditPgWcGWKpx%2BqPz9owKtGfU%2BOUpWbGvTgUtuAw%40mail.gmail.com.

Reply via email to