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.2.0.tar.gz (3.5 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.2.0.tar.gz.

File metadata

File hashes

Hashes for bear_django_request_normalizer-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aadef015713f66dbfdb484974aa2bc855ee240da990494c9962073ba0cab236a
MD5 117db1900d99deaf0819215490531746
BLAKE2b-256 4469f58298ec7bcddb3b537f9be054d81185a54bb760bb4579edd4b918149c17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bear_django_request_normalizer-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c69e895c28675b3fa279639acf3d9682031a7cb83ca5953c9f9e3071e23c36d
MD5 b302972c68e8cf61caa046bcab942b5b
BLAKE2b-256 ea7e948437b33aee2967fcd8987329655718581291400c2a2524f3de592c890d

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