Refreshing the file form

Hello everyone,

When I select the file and import it, if there is an error, it gives a warning with sweetalert. Afterwards, when I press the ok button and close the warning, the home.html page refreshes, but only the import part appears on the screen. Do you have any idea how to fix it? Thanks in advance.



def home(request):
if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            newdoc = Document(docfile = request.FILES['docfile'])

            file_path = os.path.join(BASE_DIR, newdoc.docfile.url)
            error = save_new_sample_from_csv(file_path)

            # return HttpResponseRedirect("/")
            return render(request, 'home.html', {'errors': str(error)})
        form = UploadFileForm() # A empty, unbound form

    return render(request, 'home.html', { 'form': form})


<form action="{% url 'home' %}" method="POST" enctype="multipart/form-data">
            {% csrf_token %}
            <div class="container">
              <div class="row justify-content-md-center">
                <div class="col col-lg-2">
                  {{ form.as_p }}
                <div class="col col-lg-2" style="margin-left: 10px;">
                  <input type="submit" value="Import" />

home.html -script

{% if errors != 'None' and errors %}
    <!-- sweetalert js -->
    <script src="//"></script>
      var m = "Cannot import the csv file. Please refresh the page.";{ icon: 'error', iconHtml: '<i class="fa fa-warning"></i>', text: m, confirmButtonColor: '#fff', color: '#000', background: 'rgba(0, 0, 0, 0.7)', allowEscapeKey: false,
        showClass: {
          popup: 'my-icon'   // disable popup animation css
  {% endif %}

What request is being sent to the server? Is it issuing a GET for that same page?