Skip to main content

A simple package for DRF errors formatting

Project description

Verbose Errors

A simple package for DRF errors formatting

Requirements

  • Python 3.6.8 or newer
  • Django 3.2.19 or newer
  • Django Rest Framework 3.14.0 or newer

Formatting

This package provides the exception handler that formats handled DRF exceptions into verbose error response

Generic error

{
  "errors": [
    {
      "field": null,
      "messages": [
        "You do not have enough permissions to perform this action"
      ]
    }
  ]
}

Error related to an object field

{
  "errors": [
    {
      "field": "name",
      "messages": [
        "This field is required", 
        "This field can not be null"
      ]
    }
  ]
}

Setting up

Install this package using pip

pip install djangorestframework-verbose-errors

Register the exception handler

REST_FRAMEWORK = {
    'EXCEPTION_HANDLER': 'rest_framework_verbose_errors.views.exception_handler'
}

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page