Reputation: 14144
Is to disable OPTIONS
method globally.
According to the official Django REST docs (https://www.django-rest-framework.org/api-guide/metadata/), the proper way to do it is to set DEFAULT_METADATA_CLASS
to None
.
This resolves the problem. After trying to send the OPTIONS curl request, the server responds with the 405
.
However the API Browser would still show methods under Allow that are actually not allowed:
How to hide not-supported methods under Allow in Django API Browser?
Upvotes: 2
Views: 653
Reputation: 14144
After checking the Disable a method in a ViewSet, django-rest-framework, it turned out there are at least 3 good approaches to address this:
ModelViewSet
It was decided to:
DEFAULT_METADATA_CLASS
to None
(to make sure non-defined methods are not exposed).http_method_names
for each ViewSet (to hide them in the Browser API).Upvotes: 1