Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(django): Add example to trigger an error #1009

Merged
merged 1 commit into from
May 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions src/collections/_documentation/platforms/python/django.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,41 @@ sidebar_order: 2
The Django integration adds support for the [Django Web Framework](https://www.djangoproject.com/)
from Version 1.6 upwards.

1. Install `sentry-sdk`:
Install `sentry-sdk`:

```bash
$ pip install --upgrade 'sentry-sdk=={% sdk_version sentry.python %}'
```
```bash
$ pip install --upgrade 'sentry-sdk=={% sdk_version sentry.python %}'
```

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

2. To configure the SDK, initialize it with the Django integration in your ``settings.py`` file:
```python
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[DjangoIntegration()]
)
```

```python
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
You can easily verify your Sentry installation by creating a route that triggers an error:

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[DjangoIntegration()]
)
```
```py
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.
<!-- ENDWIZARD -->

## Behavior

* All exceptions leading to an Internal Server Error are reported.
Expand Down