How can I get the data from a POST request using regular function. Django

I have this code from my views.py that working well, getting the data from my node js.

from django.views.decorators.csrf import csrf_exempt
import json

@csrf_exempt
def overview(request):
    if request.method == 'POST':
    post_data = json.loads(request.body.decode("utf-8"))
    value = post_data.get('data')
    print(value)

    return render(request, 'myhtml')

now, I'm trying to use this code in another py file, regular function in my graph. py but it's not working. It's not showing any error and not printing any.

def update_extend_traces_traceselect(request):
    if request.method == 'POST':
        post_data = json.loads(request.body.decode("utf-8"))
        value = post_data.get('data')
        print(value)

I think the request is not working in a regular function. Is there another way to get the data?

You can use the dash Store to store the data from django, and have the callback depend on the State of the Store. Please take a look at the dash Store documentation

Back to Top