Passing A JavaScript Variable In An HTML File To A Django View Function

Yes Mr. Whitesell.

I have tried both of the following lines in the JavaScript section:

location = "{% url 'facial-login-result' %}";
location.assign("{% url 'facial-login-result' %}");

The following is the event listener where I have tried this in JavaScript:

sendButton.addEventListener('click', function(e) {
        console.log(canvas.toDataURL());
        const link = document.createElement('a');
        link.download = 'SubmittedFacialImage.jpg';
        link.href = canvas.toDataURL();
        link.click();
        link.delete;

        location = "{% url 'facial-login-result' %}";
        // location.assign("{% url 'facial-login-result' %}");
    });

By looking at the terminal, I can say that I am successfully going inside the view function named FacialLoginResult that handles the URL pattern ‘facial-login’result’ because I see “Hello Duck” in the terminal.

Shouldn’t the next line which is return render(request, 'users/FacialLoginResult.html') be executed after “Hello Duck” as the following view function FacialLoginResult demonstrates:

def FacialLoginResult(request):
    print("Hello Duck")
    return render(request, 'users/FacialLoginResult.html')

Terminal: