Reputation: 1552
i am trying to get all query parameters out of an request
url/?animal__in=dog,cat&countries__in=france
I tried
animals = request.GET.get('animal__in','')
countries = request.GET.get('countries__in','')
but then animals and countries are not lists, they are just strings. Is there a more django way to do this whole capturing?
Edit: Its important that i am using it in django-admin for filtering, where these two are not the same:
url/?animal__in=dog,cat&countries__in=france
url/?animal__in=dog&animal__in=cat&countries__in=france
Upvotes: 0
Views: 1377
Reputation: 1552
split(',') works fine, not really django though
animals = request.GET.get('animal__in','').split(',')
countries = request.GET.get('countries__in','').split(',')
Upvotes: 1
Reputation: 599450
Send the parameters in the proper HTTP format:
?animal__in=dog&animal__in=cat&countries__in=france
and do
request.GET.getlist('animal__in')
Upvotes: 1