AJAX not working on Django and returning 500 Error

I'm trying to send an AJAX request from my template that takes you to a url and runs the view function. However, I'm getting a 500 Error in my console. The error in Django log says: TypeError: delete_appointment() missing 1 required positional argument: 'appointment_id' My view is also using a custom decorator, all required code is below:

Decorator

def user_has_delete(func, redirect_url="Home:Deny"):
    def wrapper(request, *args, **kwargs):
        if request.user.is_anonymous:
            return redirect(redirect_url)
        if request.user.is_authenticated:
            if not request.user.is_denier:
                return redirect(redirect_url)
            else:
                return func(request, *args, **kwargs)
    return wrapper

URL Pattern

path('Vet/DenyAppointment/<int:appointment_id>', views.delete_appointment)

View

@user_has_delete
@never_cache
def delete_appointment(request, appointment_id):
    appointment = get_object_or_404(Appointments, pk=appointment_id)
    appointment.delete()
    return redirect('Dashboard')

Template Portion

{% for appointment in appointments %}
                        <div class="col-sm-12 col-lg-8 AppointmentDiv offset-sm-0 offset-lg-2 Space-b-sm">
                            <h2>{{ appointment.fullDate }}</h2>
                                <ul>
                                    <li>{{ appointment.title }}</li>
                                    <li>{{ appointment.day }}</li>
                                </ul>
                            <button type="submit" class="theme" id='{{ appointment.id }}' onclick="deleteAppointment({{ appointment.id }})">Delete Appointment</button>
                        </div>
                    {% endfor %}

AJAX

<script>
            function deleteAppointment(appointmentId) {
                $.ajax({
                    url: '/Vet/DenyAppointment/' + appointmentId,
                    type: 'GET',
                    success: function(response) {
                        window.location.href = "/Dashboard";
                    }
                });
            }
        </script>

Fixed. I wasn't sending data in my AJAX just appending the appointment id in url. Then I needed to configure my decorator to accept additional parameters.

Back to Top