Я пытаюсь добавить переменную сеанса, но она не доступна из другой функции, пока первая функция еще работает, пример ниже
def index(request):
request.session['logs'] = [] #I define the new variable here in session
return render(request,"index.html")
def assigntoken(request):
#I got list of users from post request to assign token to each of them I call a class called AssignToken
v = AssignToken()
#AssignToken class has attribute called log_lst I assign it to session
request.session['log'] = v.log_lst #by making v global I can access it from another function while it still running, but request.session['logs'] is still empty until function finish, why?
v.start(users) #this will start loop in users list to assign tokens
return redirect('/result')
def result(request):
#while assigntoken function still running I should be able to access /result to see live logs but when I try to access request.session['logs'] I found it empty, it only has data after assigntoken finish running
context = {'logs':request.session['logs']}
return render(request,"results.html",context)