drf-exceptions-hog
Standardized and easy-to-parse API error responses for DRF.
What it is and what it does
DRF Exceptions Hog wraps Django REST Framework's exception handling to transform inconsistent error responses into a predictable, structured format. Instead of varying response shapes—some with field-level errors as arrays, others with a single detail string—it normalizes all exceptions to a consistent schema with type, code, detail, attr, and optional list fields. This makes frontend error parsing deterministic across languages and frameworks.
The package is configured via a single settings entry that replaces DRF's default exception handler. It supports optional error reporting hooks (useful for Sentry or NewRelic integration), nested field error flattening with customizable separators, and an opt-in mode to collect and return multiple validation errors in a single response rather than failing on the first. It requires only djangorestframework as a runtime dependency and works with Python 3.7+.
Use it for:
- Simplify frontend error parsing by ensuring all API errors follow a single, predictable JSON schema across your DRF endpoints.
- Integrate error reporting to external services (Sentry, NewRelic) by configuring the EXCEPTION_REPORTING handler.
- Display all validation failures to users in a single form submission instead of stopping at the first error.
- Provide consistent error codes and messages across multiple frontend frameworks or mobile apps consuming the same API.
- Customize error attribute naming for nested serializers using the NESTED_KEY_SEPARATOR setting.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Standardizes Django REST Framework exception responses into a consistent, machine-parseable JSON format with type, code, detail, and attribute fields to simplify frontend error handling.
Yes. Low install friction, active maintenance, no known vulnerabilities, and permissive MIT license. Install if you use Django REST Framework and want to eliminate frontend error-parsing complexity by standardizing exception responses. Skip only if you have already built custom exception handling or do not expose DRF errors to frontend clients.
Install
drf-exceptions-hog on PyPI
pip
pip install drf-exceptions-hoguv
uv add drf-exceptions-hogpoetry
poetry add drf-exceptions-hogInstalling drf-exceptions-hog
Before you install
Low install friction; single runtime dependency on djangorestframework. Actively maintained with recent commits; last release was over a year ago but repository remains active with no archived status.
License in practice
MIT license (permissive); you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install drf-exceptions-hog
# In settings.py:
REST_FRAMEWORK = {
"EXCEPTION_HANDLER": "exceptions_hog.exception_handler",
}
# Exceptions now return standardized JSON:
# {"type": "validation_error", "code": "required", "detail": "...", "attr": "field_name"}
Requires Django 3.1+ and Python 3.7+; only supports JSON responses.
Verify before relying
- Whether the package handles all DRF exception types or only a documented subset.
- Performance impact when exception reporting is enabled in production.
- Compatibility with Django versions beyond 3.2.x (latest tested version in fact sheet).
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — djangorestframework |
| Maintenance | actively maintained — 1,194 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,092,643/month — #3,301 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: drf_exceptions_hog-0.4.0-py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
drf-standardized-errorsConverts all Django REST Framework API error…
permissive · top 15,000 on PyPI
drf-rw-serializersExtends Django REST Framework with separate…
permissive · top 15,000 on PyPI
drf-jsonschema-serializerConverts Django REST Framework serializers to…
permissive · top 15,000 on PyPI
drf-dynamic-fieldsProvides a Django REST Framework mixin that…
permissive · top 15,000 on PyPI
drf-api-loggerCaptures and logs Django REST Framework API…
permissive · top 15,000 on PyPI
drf-recaptchaAdds reCAPTCHA v2 and v3 field validation to…
permissive · top 15,000 on PyPI
drf-orjson-rendererProvides a high-performance JSON renderer and…
permissive · top 15,000 on PyPI
drf-pydanticBridges pydantic models and Django REST…
permissive · top 15,000 on PyPI
zExceptionszExceptions provides a collection of exception…
unclear · top 15,000 on PyPI
drf-extensionsProvides mixins, decorators, and utilities that…
permissive · top 5,000 on PyPI