如何在django中从views.py打开模态?有办法吗?

如何在django中从views.py打开模态?有办法吗?,django,Django,我有一个django应用程序。当用户单击submit按钮时,两个modals将依次显示,每个modals都必须在my django应用程序的views.py中执行不同的功能。我正在尝试编写代码,但问题并不容易,我到处都找了,找不到答案 我必须用以下方式编写代码: views.py def submit(request): #first modal should pop up which has two options. #second modal should pop up whic

我有一个django应用程序。当用户单击submit按钮时,两个modals将依次显示,每个modals都必须在my django应用程序的views.py中执行不同的功能。我正在尝试编写代码,但问题并不容易,我到处都找了,找不到答案

我必须用以下方式编写代码:

views.py

def submit(request):
   #first modal should pop up which has two options.
   #second modal should pop up which also has a two options.
当用户单击任何按钮时,每个按钮也应调用views.py中的不同函数

html


标题
更新数据
#用户单击表单中的按钮,应弹出模式
#然后弹出两个情态动词
#第一个模态有两个按钮
#当用户单击“更新”按钮时,应调用视图中的函数,也应调用第二模态
应该弹出
更新更改
&时代;
#当用户点击更新按钮时,另一个模式也会弹出
应调用视图中的另一个函数。

您可以通过使用模态系统来执行此操作,您可以检查


在模板中,如果第一个条件为“显示模式1”,否则为“显示模式2”,则使用条件为“显示模式1”,只需确保该模式有两个不同的ID,以便它们可以清楚地打开。打开模式窗口需要在前端代码中完成,而不是在后端的Django views.py文件中完成。提示:
javascript
ajax
回答问题后请不要更改。如果你有新问题,请单独提问。
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


 <button class="btn btn-danger custom" style="position:absolute; left:800px; top:180px;" type="submit">Update the data</button>
                    
                
# user clicks a button in form and modal should pop up
# then 2 modals should pop up
# the first modal has two buttons 
# when user clicks the update button the function in the views should be called and also 2nd modal 
should pop up


     <!--modal 1-->
        <div aria-hidden="true" aria-labelledby="exampleModalLabel" class="modal fade" id="UpdateModal" role="dialog"
             tabindex="-1">


        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Update Changes</h5>
                    <button aria-label="Close" class="close" data-dismiss="modal" type="button">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
#when user clicks update button another modal should pop up as well as 
another function in the views should be called.

    </body>
    </html>