DJango middleware that returns 404s as JSON instead of default html response
When using Django for a restuful API, for example with DRF, it makes sense to return errors as JSON, which is what happens with 400s, 403s, etc. since they are generated by DRF themselves i.e `serializer.is_valid(raise_exception=True)` This however is not the case with 404s.
This middleware remedies this problem by intercepting 404 responses and turning them into JSON responses.
Please note that middleware [changed in django 1.10](https://docs.djangoproject.com/en/1.10/topics/http/middleware/) and thus this pacakge requires django version >= 1.10.
```python
MIDDLEWARE = [
# Should come after any django middleware such as CommonMiddleware
'django_json_404_middleware.JSON404Middleware',
]
```
# Installation
`pip install django-json-404-middleware`
Metadata
Release files for django-json-404-middleware 0.0.1
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 |
|---|---|---|---|---|
| django-json-404-middleware-0.0.1.tar.gz | 2.2 kB | Without provenance | Details for django-json-404-middleware-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_json_404_middleware-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for django_json_404_middleware-0.0.1-py3-none-any.whl |
Total release size: 6.2 kB
Release files / django-json-404-middleware-0.0.1.tar.gz
| Download URL | django-json-404-middleware-0.0.1.tar.gz |
|---|---|
| Size | 2.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd38450284e198a05df890296fa87b0fade9ff2dba2380bb4f528b83b750964c
|
|
BLAKE2b-256 checksum How to use checksums |
7b26579fc2306bc5899456243e2157f1e593a63300aa0829206a58319d1ee9c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_json_404_middleware-0.0.1-py3-none-any.whl
| Download URL | django_json_404_middleware-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e133a7814a70a89188101e21fcd30be79160dcdc8571cdc707729d69c557c72
|
|
BLAKE2b-256 checksum How to use checksums |
e5394a0c23ea89a4ccea614318ac5c16c74e725cb4d8b57970c0df07963d010f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-json-404-middleware 0.0.1
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.