negotiation.py 671 B

1234567891011121314151617181920
  1. from rest_framework.negotiation import BaseContentNegotiation
  2. class IgnoreClientContentNegotiation(BaseContentNegotiation):
  3. """
  4. @sentry/browser sends an interesting content-type of text/plain when it's actually sending json
  5. We have to ignore it and assume it's actually JSON
  6. """
  7. def select_parser(self, request, parsers):
  8. """
  9. Select the first parser in the `.parser_classes` list.
  10. """
  11. return parsers[0]
  12. def select_renderer(self, request, renderers, format_suffix):
  13. """
  14. Select the first renderer in the `.renderer_classes` list.
  15. """
  16. return (renderers[0], renderers[0].media_type)