DRF Standardized Errors
Standardize your DRF API error responses.
By default, the API error responses (4xx and 5xx) will look like:
{
"type": "validation_error",
"errors": [
{
"code": "required",
"detail": "This field is required.",
"attr": "name"
}
]
}
Features
- Highly customizable: gives you flexibility to define your own standardized error responses and override specific aspects the exception handling process without having to rewrite everything.
- Supports nested serializers and ListSerializer errors
- Plays nicely with error monitoring tools (like Sentry, ...)
Requirements
- python >= 3.8
- Django >= 3.2
- DRF >= 3.12
Quickstart
Install with pip
pip install drf-standardized-errors
Add drf-standardized-errors to your installed apps
INSTALLED_APPS = [
# other apps
"drf_standardized_errors",
]
Register the exception handler
REST_FRAMEWORK = {
# other settings
"EXCEPTION_HANDLER": "drf_standardized_errors.exception_handler"
}
Notes
Standardized error responses when DEBUG=True for unhandled exceptions are disabled by default. That is
to allow you to get more information out of the traceback. You can enable standardized errors instead with:
DRF_STANDARDIZED_ERRORS = {"ENABLE_IN_DEBUG_FOR_UNHANDLED_EXCEPTIONS": True}
Links
- Documentation: https://drf-standardized-errors.readthedocs.io/en/latest/
- Changelog: https://github.com/ghazi-git/drf-standardized-errors/releases
- Code & issues: https://github.com/ghazi-git/drf-standardized-errors
- PyPI: https://pypi.org/project/drf-standardized-errors/
Licence
This project is MIT licensed.
Metadata
Release files for drf-standardized-errors 0.10.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drf-standardized-errors-0.10.2.tar.gz | 23.2 kB | Without provenance | Details for drf-standardized-errors-0.10.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_standardized_errors-0.10.2-py3-none-any.whl | Python 3 | none | any | Details for drf_standardized_errors-0.10.2-py3-none-any.whl |
Total release size: 31.6 kB
Release files / drf-standardized-errors-0.10.2.tar.gz
| Download URL | drf-standardized-errors-0.10.2.tar.gz |
|---|---|
| Size | 23.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ccc46d78455b1438c40d01567e5c47b8c141b61bde37dc8d62ecf5bf4e87b3ee
|
|
BLAKE2b-256 checksum How to use checksums |
7840b0ee3a4cc1718a9f774ceba1f7ff34c1514a3a52ea3b0b6c4f30a79f71d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.27.1
|
Release files / drf_standardized_errors-0.10.2-py3-none-any.whl
| Download URL | drf_standardized_errors-0.10.2-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a693c8e1eefbc040395839c555f645591f1f75c717ea0b87c4ccc1a4a6552f51
|
|
BLAKE2b-256 checksum How to use checksums |
8d4d5a00956c7916c7aff55bbf322b24377adaadfc8c18ed0adb05109e227e29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.27.1
|
Security for drf-standardized-errors 0.10.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.