Install our Python SDK using
$ pip install --upgrade sentry-sdk==0.9.0
Import and initialize the Sentry SDK early in your application’s setup:
import sentry_sdk sentry_sdk.init("https://firstname.lastname@example.org/xxxx")
You can cause a Python error by inserting a divide by zero expression into your application:
division_by_zero = 1 / 0
The Django integration adds support for the Django Web Framework from Version 1.6 upwards.
$ pip install --upgrade 'sentry-sdk==0.13.2'
To configure the SDK, initialize it with the Django integration in your
import sentry_sdk from sentry_sdk.integrations.django import DjangoIntegration sentry_sdk.init( dsn="https://email@example.com/18xxxx", integrations=[DjangoIntegration()] )
You can easily verify your Sentry installation by creating a route that triggers an error:
from django.urls import path def trigger_error(request): division_by_zero = 1 / 0 urlpatterns = [ path('sentry-debug/', trigger_error), # ... ]
Visiting this route will trigger an error that will be captured by Sentry.