Closed
Description
I wanted to make api such that they only accept Json data. As per the documentation i changed DEFAULT_PARSER_CLASSES settings but it doesn't have any effect. Views are still accepting multipart form-data as well as x-www-form-urlencoded. My settings.py have below dictionary.
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
),
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
),
'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
),
# 'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer', ),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 1000
}
As per the docs
For example, the following settings would allow only requests with JSON content, instead of the default of JSON or form data.
REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
)
}
Am i missing something obvious? I am new to django-rest-framework. Please help.
Metadata
Metadata
Assignees
Labels
No labels