Django request get parameters

后端 未结 2 1801
感动是毒
感动是毒 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:10

    You can use [] to extract values from a QueryDict object like you would any ordinary dictionary.

    # HTTP POST variables
    request.POST['section'] # => [39]
    request.POST['MAINS'] # => [137]
    
    # HTTP GET variables
    request.GET['section'] # => [39]
    request.GET['MAINS'] # => [137]
    
    # HTTP POST and HTTP GET variables (Deprecated since Django 1.7)
    request.REQUEST['section'] # => [39]
    request.REQUEST['MAINS'] # => [137]
    

提交回复
热议问题