Python Django functions
I tried everything, why my 'POST request' from 'send' function isn't considered in the 'checkview' function ?
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)
Here is the error:
django.utils.datastructures.MultiValueDictKeyError: 'room_name'
I ultimately need to transfer through AJAX the plot_id variable.