Created
August 5, 2016 07:33
-
-
Save do3cc/d413ee7bc3cacedb9e3da364bcd66b51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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