Opened 8 years ago

Closed 7 years ago

#16227 closed New feature (wontfix)

Include traceback in a comment when hitting an exception in debug mode

Reported by: Daniel Watkins Owned by: nobody
Component: Core (Other) Version: 1.3
Severity: Normal Keywords:
Cc:…, Daniel Watkins, anton@…, philipkimmey, oliver@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes


As discussed on the mailing list, debugging can be a real pain using curl or when dealing with AJAX, as one has to manually parse the HTML.

It would be better if the traceback could be provided in an HTML comment near the top of the file, as this will not impact the normal display at all, but make debugging in these cases a vastly more pleasant experience.

Attachments (1)

traceback-in-comment.patch (2.2 KB) - added by Daniel Watkins 8 years ago.

Download all attachments as: .zip

Change History (14)

Changed 8 years ago by Daniel Watkins

Attachment: traceback-in-comment.patch added

comment:1 Changed 8 years ago by Matt Harasymczuk

Cc:… added

comment:3 Changed 8 years ago by Daniel Watkins

Cc: Daniel Watkins added

comment:4 Changed 8 years ago by Aymeric Augustin

Triage Stage: UnreviewedDesign decision needed
UI/UX: set

comment:5 Changed 8 years ago by Anton Strogonoff

Cc: anton@… added

comment:6 Changed 8 years ago by Julien Phalip

Type: UncategorizedNew feature

comment:7 Changed 8 years ago by philipkimmey

I've been thinking about this one quite a bit, and my suspicion is the most common inconvenience is seeing the full HTML dump when making AJAX requests.

I'm curious how commonly people are using curl (or similar methods).

At least personally, maybe 35% of the time I see an error message it's in Chrome's debug console.

My personal preference would be to simply have massively simplified templates (e.g. not HTML) for the common case of AJAX requests. We could have inline TECHNICAL_AJAX_*_TEMPLATE or something along those lines. Then we can just use request.is_ajax() to choose the template.

Although it doesn't resolve the case of using curl, if AJAX is the common case, I think it would be worth the minor increase in complexity.

If there is interest in something along these lines, I would be happy to contribute a patch.

comment:8 Changed 8 years ago by philipkimmey

Cc: philipkimmey added

comment:9 Changed 8 years ago by Ramiro Morales

Resolution: duplicate
Status: newclosed

Duplicate of #10841.

comment:10 Changed 8 years ago by Oliver Beattie

Cc: oliver@… added
Resolution: duplicate
Status: closedreopened

I'm reopening this as I think the scope of this is different to #10841.

While that helps a great deal for debugging AJAX requests, it still doesn't cover the case where the requests aren't AJAX, but your client is still not a browser; for instance, when debugging a REST API (when you're almost certainly going to be using command-line tools to test things).

I think it's be very helpful to include a standard-format traceback at the bottom of the document in a HTML comment; it would make debugging vastly easier. For what it's worth, this is something other frameworks are already doing (Flask springs to mind). Given how simple this is to implement, and in view that it wouldn't have any chance of introducing problems – there is already a standard-format traceback in the copy-and-paste view half way up the page after all – I think it's a total no-brainer.

comment:11 Changed 8 years ago by Aymeric Augustin

Component: UncategorizedCore (Other)

comment:12 Changed 7 years ago by Aymeric Augustin

Status: reopenednew

comment:13 Changed 7 years ago by Florian Apolloner

Resolution: wontfix
Status: newclosed

I think we don't need a feature like this, with the LOGGING framework you can easily add a console handler to 'django.request' and get a trace in the runserver console.

Note: See TracTickets for help on using tickets.
Back to Top