How to access "context" from http request between two django apps

So i'm fairly new to django, html, and javascript.

In my first app, I have a button that when I click it, it invokes an $.ajax type "GET" function. In the script of the html template of app1, I have the following:

$('#btn_to_app2').click(function () {
            if(Object.keys(name).length > 0){
                $.ajax(
                    {
                        type:"GET",
                        url:"to_app2",
                        data:{
                            'name': JSON.stringify(name),
                            'place': JSON.stringify(place),
                        },
                        success: function (data) {
                            if(data["noted"] == 1){
                                window.location.href = "http://" + window.location.host + "/app2/";
                            }
                        }
                    }
                )
            }

The accessed url refers to a view function (defined in the url.py and views.py files of the corresponding app1).

def to_app2(request):
    if request.is_ajax() and request.method == 'GET':
        name = json.loads(request.GET['name'])
        request.session['name'] = name

        place = json.loads(request.GET['place'])
        request.session['place'] = place
        return JsonResponse({
            'noted': 1,
        })

The data obtained is send to the next app using a http request. In the views.py file of app2, I have the following bit of code:

def app2(request):
    
    context = {
        'name': request.session['name'],
        'place': request.session['place']
    }
    
    return render(request, 'app2.html', context)

How can I now access the information contained in the "context" variable within the script of the html-file of app2?

I have tried the let name = {{ name | safe }}; framework, with quotes and without, but that doesn't seem to work.

Back to Top