How to Solve NameError: name 'ensure_csrf_cookie' is not defined -- django

Erorr: name 'ensure_csrf_cookie' is not defined

NameError: name 'ensure_csrf_cookie' is not defined

Solution: Import the 'ensure_csrf_cookie' module

# Add the following line to the top of your code
from django.views.decorators.csrf import ensure_csrf_cookie

 

For more information:
django ensure_csrf_cookie