Skip to content

Instantly share code, notes, and snippets.

@nottrobin
Created March 3, 2015 13:12
Show Gist options
  • Select an option

  • Save nottrobin/5b7fc7fd8ae08c2b1ea3 to your computer and use it in GitHub Desktop.

Select an option

Save nottrobin/5b7fc7fd8ae08c2b1ea3 to your computer and use it in GitHub Desktop.
PrettyAuthenticationFailed exception for djangorestframework
from rest_framework.exceptions import AuthenticationFailed
class PrettyAuthenticationFailed(AuthenticationFailed):
"""
A fork of the djangorestframework AuthenticationFailed exception
to simply allow the `detail` parameter to contain fully formed
JSON objects, rather than just text
"""
def __init__(self, detail=None):
if detail is not None:
self.detail = detail
else:
self.detail = force_text(self.default_detail)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment