Skip to main content

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 integer 0 for ID fields to None.
  • Cleans Email: Removes spaces and lowercases email fields.
  • Handles All Data: Works seamlessly with GET parameters, application/json, multipart/form-data, and x-www-form-urlencoded data.
  • Configurable: You can enable/disable the middleware or specify which URL prefixes it should act on.

Installation

pip install django-request-normalizer

Usage

  1. Add the middleware to your MIDDLEWARE list in settings.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bear_django_request_normalizer-0.3.0.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file bear_django_request_normalizer-0.3.0.tar.gz.

File metadata

File hashes

Hashes for bear_django_request_normalizer-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f379a79e9abed744d8c100cfb3bae69cca6ea9638ab3d91d2202967626cb2dce
MD5 b336c887c24cebade76d24957a0597d8
BLAKE2b-256 9bfadadfeba113d931072aec8f307fa9a56ccaf075cb07370002f7c9f252be28

See more details on using hashes here.

File details

Details for the file bear_django_request_normalizer-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bear_django_request_normalizer-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 928638c47c64278e171137dbaeac313e0aa28d8f01231327a7005d09f9671f74
MD5 f303c0b4d3c9b1f07315e17bef698586
BLAKE2b-256 30504a266c4a586c5671a7d004430ff9efa6db8ff3f2d7a569fe1b869627b59f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page