Disabling CSRF validation worked for me. I know this is not as reliable as extracting CSRF middleware from your project, but it worked for me.
Here is how I did it:
Step 1. Create a new application in your project and name it middle (that's what I called it) with python manage.py startapp middle
Step 2. Open the "apps.py" file in a new application folder and make the appropriate changes so that the code looks something like this:
from django.apps import AppConfig from django.utils.deprecation import MiddlewareMixin class MiddleConfig(AppConfig): name = 'middle' class DisableCSRF(MiddlewareMixin): def process_request(self, request): setattr(request, '_dont_enforce_csrf_checks', True)
(Note: your first call may differ depending on what you named your project)
Step 3. Remove 'django.middleware.csrf.CsrfViewMiddleware' django.middleware.csrf.CsrfViewMiddleware "from the MIDDLEWARE list of your settings.py file in your project directory and add another entry to the MIDDLEWARE list: 'middle.apps.DisableCSRF'
(Note: use the new application name instead of the middle if you named the new application with a different name)
The MIDDLEWARE list in your settings.py file should look something like this:
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', # 'django.middleware.csrf.CsrfViewMiddleware', 'middle.apps.DisableCSRF', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ]
I hope this works for you guys too.
(see this post for more information on disabling CSRF validation in django: how to disable CSRF validation in Django ? )
Thank you.