Proper way to handle multiple forms on one page in Django

后端 未结 10 2232
既然无缘
既然无缘 2020-11-22 09:19

I have a template page expecting two forms. If I just use one form, things are fine as in this typical example:

if request.method == \'POST\':
    form = Au         


        
10条回答
  •  再見小時候
    2020-11-22 09:47

    You have a few options:

    1. Put different URLs in the action for the two forms. Then you'll have two different view functions to deal with the two different forms.

    2. Read the submit button values from the POST data. You can tell which submit button was clicked: How can I build multiple submit buttons django form?

提交回复
热议问题