-
-
Notifications
You must be signed in to change notification settings - Fork 658
[DOCS] Django Integration for User Feedback #945
Comments
I suppose we could do provide a built-in replacement to server_error which handles passing in the required context from Sentry. There's good reasons you don't want context in general to be available, but we can guarantee safety around things we provide. |
In django >= 2.0
|
I guess It does say something in the Message Reference section, but I missed it because there wasn't anything in the User Feedback Section. https://docs.sentry.io/clients/python/integrations/django/#message-references |
Also as an FYI you might want to suggest a server error view like the following so you can dynamically insert the dsn.
|
I also came across this error today. I was following the docs here and inconveniently it doesn't mention the step of overriding the 500 handler. If you follow that as shown in the top answer and then the rest of the code in the docs will help solve the problem. |
The docs for user feedback integration with Django state that it is as simple as dropping that into the
500.html
template. However, this is incorrect.Django's default
server_error()
view passes an empty context variable so the template renders and the{% if request.sentry.id %}
line always results inFalse
because there is norequest
object passed back (empty context dict).The resolution is stated in the docs where it references a custom
handler500()
view that passes the context. I feel like that needs to be included down in theUser Feedback
section somewhere, and can submit a PR if you'd like.The new documentation for User Feedback would look something like:
User Feedback
By default Django will render 500.html, so simply drop the following snippet into your template:
Then override the default 500 handler to include the context information. In your
URL Conf
(base urls.py) add:Then define that view as:
Note
Because Django's default
server_error()
passes an empty context variable we need to create a custom 500 error handler to pass the request context.The text was updated successfully, but these errors were encountered: