request.POST get multiple values

Posted: February 24th, 2010 | Author: Davo | Filed under: Django | Tags: , , | 4 Comments »

The QueryDict.getlist() allows to get all the checkbox(or select list) values from the request.POST/GET object.

Let’s assume we have a simple form with the following checkboxes. Each checkbox contains an ID of an artist.

... ...

In views.py :

def handle(request):
    if request.method == 'POST':
         artists = request.POST.getlist('artists') # now artists is a list of [1,2,3]