Django ведет себя странно при установке IIS на сервере Windows

У меня есть следующее представление, которое позволяет мне сохранять информацию многошагового приложения.

def saveNewApplication(request, *args, **kwargs):
educationList = [ val for val in pickle.loads(bytes.fromhex(request.session['education'])).values() ]
basicInfoDict = pickle.loads(bytes.fromhex(request.session['basic_info']))
documentsDict = pickle.loads(bytes.fromhex(request.session['documents']))

applicant, created = ApplicantInfo.objects.update_or_create(
    applicantId=request.session['applicantId'],
    defaults={**basicInfoDict}
)
if created:
    #saving the diplomas
    for education in educationList:
        Education.objects.create(applicant=applicant, **education)
    with open(f"{documentsDict['cv_url']}/{request.session['file_name']}", 'rb') as f:
        Documents.objects.create(
            applicant=applicant, 
            cv =File(f, name=os.path.basename(f.name)), 
            langue_de_travail = documentsDict['langue_de_travail']
        )
    #remove the temporary folder
    shutil.rmtree(f"{documentsDict['cv_url']}")
    
else:
    educationFilter = Education.objects.filter(applicant=applicant.id)
    for idx, edu in enumerate(educationFilter):
        Education.objects.filter(pk=edu.pk).update(**educationList[idx])

    #updating the documents
    document = get_object_or_404(Documents, applicant=applicant.id)
    if documentsDict['cv_url']:
        with open(f"{documentsDict['cv_url']}/{request.session['file_name']}", 'rb') as f:
            document.cv = File(f, name=os.path.basename(f.name))
            document.save()
    document.langue_de_travail = documentsDict['langue_de_travail']
    document.save()

languagesDict = pickle.loads(bytes.fromhex(request.session['languages']))
Languages.objects.update_or_create(applicant=applicant, defaults={**languagesDict})
if 'experiences' in request.session and request.session['experiences']:
    experiencesList = [ pickle.loads(bytes.fromhex(val)) for val in request.session['experiences'].values() ]
    Experience.objects.filter(applicant=applicant.id).delete()
    for experience in experiencesList:
        Experience.objects.create(applicant=applicant, **experience)           
return JsonResponse({'success': True})

В разработке он работает отлично, но при развертывании я получаю 404 ошибку по этой строке get_object_or_404(Documents, applicant=applicant.id) что означает, что создание ложно. и я не могу понять почему так. Самое странное, что если я закомментирую весь блок else, он также возвращает ошибку 500, но на этот раз я нажимаю на ссылку консоли, она показывает правильный ответ, а не перенаправление {success:true}. Ниже приведен мой javascript fonction для обработки представления.

applyBtn.addEventListener("click", () => {
  var finalUrl = "/api/applications/save-application/";
  fetch(finalUrl)
  .then(res => res.json())
  .then(data => {
    if (data.success) {
      window.location.href = '/management/dashboard/';
    } else {
      alert("something went wrong, Please try later");
    }
  })
});

Я использую postgresql в качестве базы данных Я удалял дважды, но ничего. url файл находится здесь.

 path("api/applications/save-application/", views.saveNewApplication, name="save-new-application"),
path("api/applications/delete-applicant/<slug:applicantId>/", views.deleteApplicant , name="delete-applicant"),
path('api/edit-personal-info/', editPersonalInfo, name="edit-personal-info"),

Любая помощь или объяснение будут высоко оценены. Заранее спасибо.

Вернуться на верх