Skip to content

HTML sometimes returned when Accept: application/json is provided #3362

@pmdarrow

Description

@pmdarrow

DRF returns HTML in a few different places even when the Accept: application/json header is provided. Examples:

  • When DEBUG=True and I make a request that returns a 500, I'll get Django's debug page and not a nicely formatted JSON response.
  • When DEBUG=False and I make a request that returns 404 (outside of DRF-managed urls) or 500, the default 404.html or 500.html templates are returned.

It would be nice to have optional settings and/or handlers provided that could be enabled to always return JSON when Accept: application/json is provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions