Shiva Krishna Bavandla
Shiva Krishna Bavandla

Reputation: 26728

Unable to get all values from the GET dictionary in django

I have a django view that gets data from request.GET

def get_values_from_GET(request):
    print request.GET, >>>>
    print request.get('ids[]', None)
    return redirect('hurray')

Output

<QueryDict: {u'ids[]': [u'15', u'14']}> >>>>
14 >>>>

So i can able to see the list of values in request.GET, but can see only one value when trying to access, so y this happening ?

Upvotes: 2

Views: 222

Answers (1)

falsetru
falsetru

Reputation: 369324

Use QueryDict.getlist:

request.GET.getlist('ids[]', None)

Upvotes: 5

Related Questions