pythondjango-rest-framework

Settings REST_FRAMEWORK error DEFAULT_SCHEMA_CLASS configuration


I'm following along this tutorial. I added the "REST_FRAMEWORK" object how they describe in settings.py

REST_FRAMEWORK = {
  'DEFAULT_AUTHENTICATION_CLASSES': (
    'rest_framework_simplejwt.authentication.JWTAuthentication',
    'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
  ),
}

I get this error after running command py manage.py runserver. Any help is greatly appreciated.

error


Solution

  • You put 'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema' into the 'DEFAULT_AUTHENTICATION_CLASSES' tuple.

    How to fix:

    REST_FRAMEWORK = {
        'DEFAULT_AUTHENTICATION_CLASSES': [
            'rest_framework_simplejwt.authentication.JWTAuthentication'
        ],
        # out of DEFAULT_AUTHENTICATION_CLASSES
        'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema' 
    }