Skip to content

Instantly share code, notes, and snippets.

@cypreess
Last active June 29, 2018 10:40
Show Gist options
  • Select an option

  • Save cypreess/4313e0824f5ceb990ff34c36a8d358c2 to your computer and use it in GitHub Desktop.

Select an option

Save cypreess/4313e0824f5ceb990ff34c36a8d358c2 to your computer and use it in GitHub Desktop.
DRF backend allowing to disable csrf force checking on views (https://stackoverflow.com/questions/30871033/django-rest-framework-remove-csrf)
from rest_framework.authentication import SessionAuthentication
class CsrfExemptSessionAuthentication(SessionAuthentication):
def enforce_csrf(self, request):
return # To not perform the csrf check previously happening
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment