无法加载资源:服务器响应状态为 500(内部服务器错误)服务器不能是服务器错误当我在 Visual 中运行它时

无法加载资源:服务器响应状态为 500(内部服务器错误)服务器不能是服务器错误当我在 Visual 中运行它时
When I run it in visual, it works, but when I deploy it to the server, the part with the url is https://domain/finance/ 


$.ajax({
    url: 'https://example.ca/finance/',
    beforeSend : function(jqXHR, settings) {
               jqXHR.setRequestHeader("x-csrftoken", '{{ csrf_token }}');
                        },
                        data: data,
                        processData: false,
                        method: 'POST',
                        contentType: false,
                        enctype: 'multipart/form-data',
                        success: function ( qayidanData ) {
                            if( qayidanData == "True"){
                            $('.requiredS2, .requiredS1').each(function () {
                                $(this).val('');      
                            });
                            $('#step2').hide();
                            $('#step1').show();
                            Swal.fire('You have successfully registered');
                            
                          }
                        }
    
                    });
    jquery-3.6.0.min.js:2 XHR failed loading: POST "https://example.ca/finance/".
    send    @   jquery-3.6.0.min.js:2
    ajax    @   jquery-3.6.0.min.js:2
    (anonymous) @   (index):433
    dispatch    @   jquery-3.6.0.min.js:2
    v.handle    @   jquery-3.6.0.min.js:


def finance(request):
    
    address_list = Address.objects.all()
    
    context =  {
        'address_list': address_list
    }
    
    if request.method == "POST":
        
        
        first_name = request.POST.get('first_name')
        last_name = request.POST.get('last_name')
        email = request.POST.get('email')
        phone_number = request.POST.get('phone_number')
        employer_name = request.POST.get('employer_name')
        employer_phone_number = request.POST.get('employer_phone_number')
        postal_code = request.POST.get('postal_code')
        street_name = request.POST.get('street_name')
        province = request.POST.get('province')
        city = request.POST.get('city')
        current_occupation = request.POST.get('current_occupation')
        annual_gross_income = request.POST.get('annual_gross_income')
        years_with_current_employer = request.POST.get('years_with_current_employer')
        home_ownership_type = request.POST.get('home_ownership_type')
        mortgage_company_or_landlord = request.POST.get('mortgage_company_or_landlord')
        monthly_rent_or_mortgage_payment = request.POST.get('monthly_rent_or_mortgage_payment')
        preferred_lender = request.POST.get('preferred_lender')
        print(email)
        print(mortgage_company_or_landlord)
        
        data = Finance.objects.create(
            first_name = first_name,
            last_name = last_name,
            email = email,
            phone_number = phone_number,
            employer_name = employer_name,
            employer_phone_number = employer_phone_number,
            postal_code = postal_code,
            street_name = street_name,
            province = province,
            city = city,
            current_occupation = current_occupation,
            annual_gross_income = annual_gross_income,
            years_with_current_employer = years_with_current_employer,
            home_ownership_type = home_ownership_type,
            mortgage_company_or_landlord = mortgage_company_or_landlord,
            monthly_rent_or_mortgage_payment = monthly_rent_or_mortgage_payment,
            preferred_lender = preferred_lender,
        )
        
        if data:
            print(data)
            return render(request,'register2.html')
            
    
    return render(request,'finance.html')

一切正常,但服务器没有提交

相关内容