[Fixed]-CSRF token not getting inserted into template

1👍

Why are you using the Context class? render constructs a RequestContext for you when passed a dict, and it’s that which you need in order to run context processors including the one that inserts the CSRF token. Just drop that import and use a dict:

    context = {'qid':qid,'questionData':questionJSON}
    return render(request,'frame.html',context)

You don’t need the Template class or the variable you get from it, either – again, render does all that for you, and you’re not even passing that template variable anywhere.

Leave a comment