A Django middleware to clean and normalize incoming request data (GET, POST, JSON).
Project description
Django Request Normalizer
A configurable Django middleware that automatically cleans and normalizes incoming request data before it reaches your views.
Features
- Trims Whitespace: Strips leading/trailing whitespace from all string values.
- Normalizes Booleans: Converts string values like
"true"and"false"to actual booleans. - Normalizes Nulls: Converts string
"null", empty strings""for ID fields, and integer0for ID fields toNone. - Cleans Email: Removes spaces and lowercases email fields.
- Handles All Data: Works seamlessly with
GETparameters,application/json,multipart/form-data, andx-www-form-urlencodeddata. - Configurable: You can enable/disable the middleware or specify which URL prefixes it should act on.
Installation
pip install django-request-normalizer
Usage
- Add the middleware to your
MIDDLEWARElist insettings.py. It should be placed before any middleware that accesses request data, such as DRF's authentication classes or your own views.
# settings.py
MIDDLEWARE = [
# ...
'request_normalizer.middleware.RequestNormalizerMiddleware',
# ...
]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bear_django_request_normalizer-0.3.0.tar.gz.
File metadata
- Download URL: bear_django_request_normalizer-0.3.0.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f379a79e9abed744d8c100cfb3bae69cca6ea9638ab3d91d2202967626cb2dce
|
|
| MD5 |
b336c887c24cebade76d24957a0597d8
|
|
| BLAKE2b-256 |
9bfadadfeba113d931072aec8f307fa9a56ccaf075cb07370002f7c9f252be28
|
File details
Details for the file bear_django_request_normalizer-0.3.0-py3-none-any.whl.
File metadata
- Download URL: bear_django_request_normalizer-0.3.0-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
928638c47c64278e171137dbaeac313e0aa28d8f01231327a7005d09f9671f74
|
|
| MD5 |
f303c0b4d3c9b1f07315e17bef698586
|
|
| BLAKE2b-256 |
30504a266c4a586c5671a7d004430ff9efa6db8ff3f2d7a569fe1b869627b59f
|