How can I access the form submit button value in Django?

前端 未结 3 1543
春和景丽
春和景丽 2020-12-09 09:19

I have a Django project that, on one page, has multiple forms (in different tags) that can be submitted to have different effects. In all cases I want the user to be redire

3条回答
  •  醉话见心
    2020-12-09 09:44

    One thing to keep in mind to prevent confusion. The name of the submit button will not show if there is only a single button in the form.

    #template.html
    
    #view.py ... 'first_button' in request.POST #False

    #template.html
    
    #view.py ... 'first_button' in request.POST #True if you clicked on that button

提交回复
热议问题