Функции Python Django

Я все перепробовал, почему мой 'POST запрос' из функции 'send' не учитывается в функции 'checkview' ?

def send(request):
    room = request.POST['room_name']
    #YAHOO API
    import yfinance as yf
    aapl = yf.Ticker(room)
    ainfo = aapl.history(period='1y')
        
    #Plot the Chart
    import plotly.graph_objects as go
    fig = go.Figure(data=go.Scatter(x=ainfo.index,y=ainfo.Close, mode='lines'))
    #x = fig.show()

    #DB inject plot
    rx = str(randint(9999,99999))
    fig.write_image("/Users/Xlibidish/Desktop/Django/static/"+room+rx+".png")

    #DB Inject from send
    plot_id = str(room+rx) 
    new_message = Message.objects.create(room=plot_id)
    new_message.save()
    return HttpResponse('All Good in send')

def checkview(self):
    send(self)
    chart_id = Message.objects.get(room=plot_id)
    return JsonResponse(chart_id.room, safe=False)

Вот ошибка:

django.utils.datastructures.MultiValueDictKeyError: 'room_name'

В конечном итоге мне нужно передать через AJAX переменную plot_id.

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