This is my function in views.py which calls the api and send the response on html page.
r = requests.post(RUN_URL, data=data)
return JsonResponse(r.json(), safe=False)
I have a global variable 'counter' which I want to return along with that r.json().
return JsonResponse(r.json(),counter, safe=False)
When I tried this code it gives me a error:
TypeError: 'int' object is not callable
You can create a dictionary where you return both the data and the counter, like:
Please do not use global variables. Global variables introduce a global state, which makes testing, refactoring, and distributing software very painful.