I'm using Django Rest Framework. I have the standard API endpoints (/login, /logout, /registration...) and I can use them without any problems but when I want to create a new record I got this "Csrf token missing" error.
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
if PRODUCTION:
MIDDLEWARE += ['django.middleware.csrf.CsrfViewMiddleware']
these are my middleware and I'm in develop mode now so there is no CsrfViewMiddleware. I'm using ModelViewSets and ModelSerializers. I've tried using @csrf_exempt decorator but it didn't work, I had the same error. I want to use my code without having csrf token for development mode, do you guys have any idea what should I do?