Skip to content

Lightrun for Django

In order to run a Django web server with the Lightrun agent please follow these steps:

  1. In the application folder, install the python agent by running python -m pip install lightrun
  2. Add the following code to your manage.py file and run your Django application as you did normally before:
    try:
        if os.environ.get('RUN_MAIN') or '--noreload' in sys.argv:
            import lightrun
            lightrun.enable(com_lightrun_server='https://app.lightrun.com/company/<YOUR_COMPANY_NAME>', com_COMPANY_SECRET='<YOUR_YOUR_COMPANY_SECRET>')
    except ImportError as e:
        print("Error importing Lightrun: ", e)
    

Last update: October 27, 2021