PricingBlogDocumentationDocsLoginRegister

Connect your Django project to GlitchTip

Install sentry-sdk into your Django project:

$ pip install --upgrade sentry-sdk

To configure the SDK, initialize it with the Django integration in your settings.py file:

import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

sentry_sdk.init(
    dsn="YOUR-GLITCHTIP-DSN-HERE",
    integrations=[DjangoIntegration()],
    auto_session_tracking=False,
    traces_sample_rate=0
)

You can verify your SDK 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('glitchtip-debug/', trigger_error),
    # ...
]

Visiting this route will trigger an error that will be captured by GlitchTip.

Configuration

Here is a more robust configuration example:

sentry_sdk.init(
    dsn="YOUR-GLITCHTIP-DSN-HERE",
    integrations=[DjangoIntegration()],
    auto_session_tracking=False,
    traces_sample_rate=0.01,
    release="1.0.0",
    environment="production",
)
  • dsn - Where to send event data too, found in GlitchTip in project settings.
  • integrations - Platform integrations such as DjangoIntegration and CeleryIntegration.
  • auto_session_tracking - Not supported, set to False.
  • traces_sample_rate - Percent of requests that are sent to GlitchTip as a performance monitoring transaction. 0.01 meaning 1%. We recommend setting to a low value to save costs/disk space.
  • release - Set release name such as "1.0". Defaults to environment variable SENTRY_RELEASE.
  • environment - Set the running environment name, such as "production". Defaults to environment variable SENTRY_ENVIRONMENT.
  • send_default_pii - Set to True to send additional PII event data. Defaults to False.
  • debug - Set to True to view more information about the SDK when something goes wrong. Defaults to False.

Content Security Policy Reporting

Using Content Security Policy (CSP)? Send reports to GlitchTip. Set your website's CSP report-uri directive to the GlitchTip Security Endpoint.

Django 6.0+ includes built-in CSP support. In settings.py set:

SECURE_CSP = {
    # ...
    "report-uri": ["your Security Endpoint here"],
}