[Django]-Django-rest-framework API test 403 {'detail': 'You do not have permission to perform this action.'}

4👍

Found out why because DEFAULT_PERMISSION_CLASSES is set as admin user so only admin role’s token can be use in my api so i changed to :

REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ),
    # 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',)
}

and now it worked

Leave a comment