How to disable the browser interface to view the django-rest-framework?

I am using django-rest-framework . It provides an awesome API that supports the Django API, which you can view yourself. But everyone can visit these pages and use the interface for adding data (POST). How to disable it?

+135
django django-rest-framework
Aug 10 2018-12-12T00:
source share
2 answers

You just need to remove the viewable API renderer from the list of supported renderings for the view.

You can do it globally, for example:

REST_FRAMEWORK = { 'DEFAULT_RENDERER_CLASSES': ( 'rest_framework.renderers.JSONRenderer', ) } 

Or for each view:

 class MyView(...): renderer_classes = [renderers.JSONRenderer] 

Besides . In many cases, it seems to me a shame that people will in any case disable the API for viewing, as this is a big help to any developers working on the API, and that doesn’t mean t give them more permissions that they otherwise had would. I see that in some cases there may be business reasons, but overall I consider this a huge asset.

+218
Oct 31 '12 at 10:56
source share

Remove 'rest_framework.renderers.BrowsableAPIRenderer', from 'DEFAULT_RENDERER_CLASSES' in your settings

0
Nov 20 '17 at 2:31 on
source share



All Articles