Eric Saupe
Eric Saupe's Blog

Eric Saupe's Blog

Get List from POST Data - Django

Eric Saupe's photo
Eric Saupe

Published on Sep 11, 2013

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Recently I tried sending a list through a form using something like <input name="my_list[]" value="some val">. When this form is submitted all of the inputs with that name are grouped together for easy access. In Django, one would think you could simply access the list using request.POST['my_list[]']. This is not the case. Using that command will give you the last value. Django says this is a feature and to get the list use request.POST.getlist('my_list[]'). Just an FYI and reminder to myself.
 
Share this