Submit Button functionality not working properly in Django

Currently, I am working in a Django project and my case is that I have a html button which is used to run python script which is in my project folder. My scenario is that I am uploading a .pcap file and then I click on html button which is used to run python script and this python script is used to fetch the logs from .pcap file. But when I disable my html button it not run the script or you can say that it doesn't submit the request. I am sharing the details:

def compliance_check(request):
  if request.method == 'POST':
    uploaded_file = request.FILES['doc']
    fs = FileSystemStorage(), uploaded_file), 'your file ' + + " has been uploaded successfully")
  return render(request, 'enroll/compliance.html')

This function is used to save the uploaded file in a folder.

def results(request):
  user_id = request.session['user_id']
  hash_id = compliance(user_id)
  request.session['hash_id'] = hash_id
  return redirect(tables_view)

This function is used to run the python script.


<!-- use to upload the file -->
<form method="post" enctype="multipart/form-data" name="myform">
                      {% csrf_token %}
                    <input type="file" id="file" name="doc" onchange="document.myform.submit()">
                    <!-- <input type="submit" name = "doc" value="Start Analyze" class="btn btn-warning btn-sm" disabled />   -->
<!-- end of uploading file -->

<!-- run the python script-->
                  <form action = "/results/" method="post" id="formABC">
                    {% csrf_token %}
                    <input type="submit" name = "doc" id="btnSubmit" value="Start Analyze" class="btn btn-default btn-sm" />
<!-- end of python running script-->

There are two different forms. One is used to upload the file and second is used to run the script.


        $("#formABC").submit(function (e){
          $("#btnSubmit").attr("disabled", true)
          return true;

This jqurey functionality is used to disable the button once it clicked. and its condition is true. But I am stuck in a situation that Start analyze button doesn't run the script when I add this jquery code. After commenting the jquery code start analyzes button runs the script.

When once .pcap file is uploaded then start analyses button must run otherwise it should be disable even no .pcap file was uploaded

Back to Top