Registry / web-framework / drf-standardized-errors

drf-standardized-errors

JSON →
library0.16.0pypypiunverified

drf-standardized-errors is a Python library for Django REST Framework that standardizes API error responses, making them consistent and easier for clients to consume. It is currently at version 0.15.0 and maintains an active release cadence, frequently adding support for new Python, Django, and DRF versions.

pip install drf-standardized-errors
INSTALL
IMPORT
SIG · DRF-STANDARDIZED-E
D
drf-standardized-errors
web-frameworkpythonv0.16.0
Install
3.7s avg
Import
Disk
70MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.16.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 70.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.7s · import 0.000s · 71MB
70MB installed
● package 70MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

exception_handler
from drf_standardized_errors import exception_handler
from drf_standardized_errors import exception_handler

To enable standardized error handling, configure `REST_FRAMEWORK['EXCEPTION_HANDLER']` in your Django settings to point to the library's exception handler.

# settings.py REST_FRAMEWORK = { "EXCEPTION_HANDLER": "drf_standardized_errors.handler.exception_handler" }
Debug
Known issues
breakingAs of v0.15.0, unhandled exceptions now return a generic error message by default to prevent sensitive data leaks. This changes the previous behavior of exposing the raw exception message.
fix
To revert to the old behavior or customize the generic message, create a custom exception handler class inheriting from `drf_standardized_errors.handler.DRFStandardizedErrorsExceptionHandler` and override `get_fallback_error_message` or `get_generic_error_response_data`.
affects: >=0.15.0
breakingIf using `drf-spectacular` (versions 0.27.0 or newer), the `SPECTACULAR_SETTINGS["ENUM_NAME_OVERRIDES"]` entries for 'ValidationErrorEnum' and 'ClientErrorEnum' must reference `choices` instead of `values`.
fix
Update your `SPECTACULAR_SETTINGS` to use `drf_standardized_errors.openapi_serializers.ValidationErrorEnum.choices` and `drf_standardized_errors.openapi_serializers.ClientErrorEnum.choices`.
affects: >=0.13.0 (when using `drf-spectacular` >=0.27.0)
gotchaImproper configuration of `REST_FRAMEWORK['EXCEPTION_HANDLER']` in `settings.py` will prevent `drf-standardized-errors` from taking effect, resulting in default DRF error responses.
fix
Ensure the `EXCEPTION_HANDLER` setting precisely matches `"drf_standardized_errors.handler.exception_handler"`.
affects: All versions
gotchaCompatibility with `drf-spectacular` for OpenAPI schema generation features is often tied to specific `drf-spectacular` versions. Refer to the release notes for precise version requirements to ensure correct schema generation (e.g., v0.14.0 enforces `drf-spectacular >=0.27`).
fix
Always check the `drf-standardized-errors` release notes or documentation for required `drf-spectacular` versions and upgrade `drf-spectacular` accordingly if experiencing schema generation issues.
affects: All versions using `drf-spectacular` integration
Upgrade
Version history
0.16.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
djangorestframeworkrequiredCore dependency for integrating with Django REST Framework.
drf-spectacularoptionalOptional dependency for OpenAPI schema generation, providing error response examples and enhanced schema support.
Agent activity
10 hits · last 30 days
node
10
Resources
drf-standardized-errors — pip install drf-standardized-errors · libregistry