[Fixed]-Sending data from view.py to a javascript in django

1πŸ‘

βœ…

i don’t know what are you do, but you send locals() as context. first, why you did this? you don’t use them in template. second, you should send your context in third parameter in render() and if you so need locals in template context, write something like this:

ctx = locals() 
ctx.update(
    js_json1 = json1,
    TotVar = tot,
) 
return render(request, 'uploaded.html', ctx)

or

ctx = {
    'locals': locals(),
    'js_json1': json1,
    'TotVar': tot,
}
return render(request, 'uploaded.html', ctx)

https://docs.djangoproject.com/en/1.10/topics/http/shortcuts/#render

πŸ‘€dd42

Leave a comment