Skip to content

Instantly share code, notes, and snippets.

@tomchristie
Last active December 15, 2015 16:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomchristie/5290867 to your computer and use it in GitHub Desktop.
Save tomchristie/5290867 to your computer and use it in GitHub Desktop.
# `views.py`
@api_view(['GET', 'POST']) # Or whatever methods the view should support.
def whatever(request):
...
return Response(some_data) # `some_data` should be any native python json-serializable stuff.
# `settings.py`
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'restframework.authentication.TokenAuthentication'
)
'DEFAULT_PERMISSION_CLASSES': (
'restframework.authentication.IsAuthenticatedOrReadOnly'
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment