I have a function that returns a render of a html (function 1). I want to change a global variable using formula 1 and the access this edited global variable in another formula (formula 2). In order to do this I think I have to return the global variable in formula 1, so the edited version can be accessed in formula 2. My problem is that function 1 already returns a render request.
global_variable = 0
def function1(request):
global_variable = 10
return render(request, 'index.html', {})
def function2(request):
print(global_variable)
excel = open(path, 'rb')
response = HttpResponse(excel.read(), content_type="app/vnd.openxmlformat.spreadsheetml.sheet")
response['Content-Disposition'] = 'attachment; filename=' + os.path.basename("Excel.xlsx")
return response
I have tried to just add in the global variable at the end of the function like so:
def function1(request):
global_variable = 10
return render(request, 'index.html', {}), global_variable
except it causes the error 'tuple' object has no attribute 'get'