Skip to content

Instantly share code, notes, and snippets.

@do3cc
Created August 5, 2016 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save do3cc/d413ee7bc3cacedb9e3da364bcd66b51 to your computer and use it in GitHub Desktop.
Save do3cc/d413ee7bc3cacedb9e3da364bcd66b51 to your computer and use it in GitHub Desktop.
if request.META['HTTP_ACCEPT'].startswith('text/html'):
return HttpResponseRedirect(self.login_url)
else:
# You are not human after all and can handle 401 better
# https://www.youtube.com/watch?v=PXYeARRyDWk
return HTTPResponse(status_code=status.HTTP_401_UNAUTHORIZED)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment