简体   繁体   中英

get value from POST request in Django

I want to get the value of the key 'result' but every time I'm trying to get it it becomes empty

if request.method == 'POST':
    result = request.POST

after printing the result

as you can see there is something there but when I'm trying to print:

request.POST.get('result')

or

request.POST['result']

I'm getting an empty string

Try this values = request.POST.getlist('result') , as request.POST.get('result') returns only the last element in array, it's '' in your case. Check this discussion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM