Using Spotlight with Django
This guide gets Spotlight up and running in Django with Sentry SDK.
1. Installation
Install Sentry SDK
Follow the Django Getting Started guide to install and configure Sentry SDK for Python/Django.
Note that you don’t need a DSN or don’t need to sign up for Sentry to use Spotlight. If you already have Sentry SDK installed, make sure you have v2.25.0 or newer.
Get and Run Spotlight
npx @spotlightjs/spotlight
docker run --rm -p 8969 ghcr.io/getsentry/spotlight:latest
curl -q https://spotlightjs.com/install.sh | sh
2. Enable Spotlight
Set SENTRY_SPOTLIGHT
environment variable to 1
1 (see our docker compose instructions if you are using Docker Compose).
That’s it! As long as Spotlight is running, and DEBUG
is set to True
in your Django settings2, our Django integration will automatically inject it into your UI.
Additional Configuration
If for some reason you do not want Spotlight to inject itself onto the pages, you can set SENTRY_SPOTLIGHT_MIDDLEWARE
environment variable to 0
.
If you are okay with the injection but want the default Django error page instead of Spotlight, you can set SENTRY_SPOTLIGHT_ON_ERROR
environment variable to 0
to only disable this part.
Footnotes
-
If, for some reason, you need to run Spotlight on a different port or domain, you can set it here instead of a “truthy” value which would use the default URL (ie.
SENTRY_SPOTLIGHT=http://localhost:3839/stream
). ↩ -
This requirement is to prevent enabling Spotlight accidentally on production environments. ↩