[Fixed]-No CSRF token after Django 1.8 form error

1👍

The actual error No module named lib appears to be because Django can’t import the CSRF_FAILURE_VIEW you have specified in your settings. You could try removing it from your settings, then Django should show the default CSRF failure page instead of the error. I can’t tell why the import is failing, because you haven’t shown what CSRF_FAILURE_VIEW or your project structure is.

To fix the CSRF error, try using the render shortcut instead of render_to_response. It renders the template with a request context, so that the csrf_token tag works.

# avoid locals() if possible!
return render(request, template, {...})

Leave a comment