Skip to main content

Simple middleware for django to extract string queries from urls

Project description

QueryStringer

Simple middleware for django to extract string queries from urls

Installation

pip install querystringer

Import

import it inside middleware in django settings

middlewares = [
  ...,
  'querystringer.middleware.QueryStringer',
  ...,
]

Usage

all requests will have an edited request dict and you can access them by request.GET['queries']

Example

our view

def home(request):
    return HttpResponse(request.GET['queries'])

then send request to /home?test=true now we should except output like this

('test', 'true')

Remove specific characters

in your settings.py add a list with QUERY_REMOVE_STRINGS name to ignore characters you want like this

QUERY_REMOVE_STRINGS = ['-', '>', '%']

then the data you get will be clean like this request to /home?test=tru>e then we get (test, true)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

querystringer-0.0.2-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

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