Django request get parameters

后端 未结 2 1802
感动是毒
感动是毒 2021-01-30 19:44

In a Django request I have the following:

POST:

How do I get the values of

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 20:14

    You may also use:

    request.POST.get('section','') # => [39]
    request.POST.get('MAINS','') # => [137] 
    request.GET.get('section','') # => [39]
    request.GET.get('MAINS','') # => [137]
    

    Using this ensures that you don't get an error. If the POST/GET data with any key is not defined then instead of raising an exception the fallback value (second argument of .get() will be used).

提交回复
热议问题