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-errorsVerified import paths — ran on the pinned version, not inferred.
To enable standardized error handling, configure `REST_FRAMEWORK['EXCEPTION_HANDLER']` in your Django settings to point to the library's exception handler.
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`.
Update your `SPECTACULAR_SETTINGS` to use `drf_standardized_errors.openapi_serializers.ValidationErrorEnum.choices` and `drf_standardized_errors.openapi_serializers.ClientErrorEnum.choices`.
Ensure the `EXCEPTION_HANDLER` setting precisely matches `"drf_standardized_errors.handler.exception_handler"`.
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.