Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: Problem reading multi valued POST variable

Tags:

python

django

I'm missing something obvious here. I am trying to process a POST request that contains a mixture of single value and multi value variables. I can get the single valued variables using request.POST.get('variable_name'), for example:

logging.debug('sale_date: ' + request.POST.get('SALEDATE'))

However, I can't get the multi value variables using request.POST.getlist('variable_name'). For example, the following returns an empty list.

prices = request.POST.getlist("IPN_PRICE")

I can't show all the fields in the request here, because it's work for a client. However this log call:

logging.debug(repr(request.POST)) 

gives this output (start only)

<QueryDict: {u'IPN_PRICE[]': [u'15.76'], ...

By the way, the request I'm trying to process is an IPN (Instant Payment Notification) from a payment processing service.

like image 548
FunLovinCoder Avatar asked Dec 17 '25 19:12

FunLovinCoder


1 Answers

prices = request.POST.getlist("IPN_PRICE[]")

This should do the trick.

like image 68
dekomote Avatar answered Dec 19 '25 10:12

dekomote



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!