python - How do I disable OPTIONS method on Django Rest Framework globally? -


i want disable options method on api built django rest framework (drf) globally (on api endpoints)

currently options call returns,

{   "parses": [     "application/json",     "application/x-www-form-urlencoded",     "multipart/form-data"   ],   "renders": [     "application/json"   ],   "name": "login oauth2",   "description": "" } 

which don't want peek into. want return blank character github on api or else.

i tried

@api_view(['post']) def my_method(request):     if request.method == 'options':             return response() 

on function based view, returns inspecting headers show,

allow →post, options, options 

which has repeated options.

how achieve it? thanks.

in settings, add like:

rest_framework = {     'default_metadata_class': none, } if debug:     # default value     rest_framework['default_metadata_class']: 'rest_framework.metadata.simplemetadata' 

you can implement own metadata class well. setting none make return http 405 on options requests.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -