Skip to main content

Django Middleware for optic

Project description

Optic Django Middleware

Build status

This module is an Django middleware using optic-sdk to capture and format HTTP data to send to Optic. We have a list of middleware available for some frameworks, if we are missing the framework join our community and suggest the next framework or develop it with us.


The module requires @useoptic/cli to be installed, instructions on installing it are available


pip install optic-django-middlewaree


The middleware takes a configuration object and captures traffic in the background as long as @useoptic/cli is installed.


Environment variables can also be used to set the values

  • ENABLE: boolean (defaults to FALSE) Programmatically control if capturing data and sending it to Optic
  • UPLOAD_URL: string (defaults to os.environ['OPTIC_LOGGING_URL']) The URL to Optics capture URL, if left blank it will expect OPTIC_LOGGING_URL environment variable set by the Optic CLI
  • CONSOLE: boolean (defaults to FALSE) Send to stdout/console for debugging
  • framework: string (defaults to '') Additional information to inform Optic of where it is capturing information
  • LOG: boolean (defaults to FALSE) Send to log file
  • LOG_PATH: boolean (defaults to ./optic.log) Log file path
  • LOCAL: boolean (defaults to TRUE) Send to optic cli
  • INTERACTION_MANAGER: string (defaults to optic_django_middleware.manager.BasicOpticManager) Manager module to control the behaviour of capturing and sending interaction


import os
from tempfile import mkdtemp
tempdir = mkdtemp('optic_django')
    'ENABLE': True,
    'LOG_PATH': os.path.join(tempdir, 'optic.log'),
    'LOG': True,
    'CONSOLE': False,
    'LOCAL': False


To start capturing data from the SDK, run your application with

api exec "python runserver"


This software is licensed under the MIT license.

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

optic-django-middleware-0.1.2.tar.gz (5.6 kB view hashes)

Uploaded source

Built Distribution

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