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

Traceback HTML not shown in browsable API #4042

Closed
ychouinard opened this issue Apr 7, 2016 · 8 comments
Closed

Traceback HTML not shown in browsable API #4042

ychouinard opened this issue Apr 7, 2016 · 8 comments
Labels
Milestone

Comments

@ychouinard
Copy link

ychouinard commented Apr 7, 2016

In the browsable API, when I submit a form and it causes a 500 error, the page gets reloaded instead of showing Django's 500 template.

For ajax requests, the 500 response is sent in plain text (https://github.com/django/django/blob/master/django/views/debug.py#L74) and in the browsable api, the page is redirected to itself when the response is not in HTML (https://github.com/tomchristie/django-rest-framework/blob/566812ac0b577f79801ec67f86f064cf39ebee01/rest_framework/static/rest_framework/js/ajax-form.js#L65)

It would be great to show the error details somehow.

@timo-piirmann
Copy link

timo-piirmann commented Apr 12, 2016

I'm also hitting this problem. Whenever I'm doing POST/PUT requests in browsable API and it fails with 500 then a GET request is automatically fired against the same url and that's what I'm going to see in the browser. The stack trace is still logged in my log file.

Also if GET request fails then the correct django full debug/stacktrace error page is shows and no extra requests are fired. Have not been able to figure out the problem

Running django 1.7.x and rest 3.3.3

@legsyl
Copy link

legsyl commented May 13, 2016

After migrating from django 1.7.1 / rest 2.3.13 to django 1.8.12 / rest 3.3.3
I encounter the same pb

@tomchristie
Copy link
Member

tomchristie commented May 16, 2016

Agree that this would be an improvement, yup.

@akhilputhiry
Copy link
Contributor

akhilputhiry commented Jun 5, 2016

I have added a patch for this. Please share your thoughts. #4172

@tomchristie
Copy link
Member

tomchristie commented Jun 6, 2016

@akarambir Not convinced that'd actually fix things, as I don't think it's where the issue is, tho I could be wrong. If you've confirmed that the change does result in fixing the required behavior then I'll reopen as described on the ticket. Thanks!

@tomchristie tomchristie added this to the 3.4.0 Release milestone Jun 14, 2016
@anoopmalav
Copy link
Contributor

anoopmalav commented Aug 4, 2016

@tomchristie Problem is in Browsable API only because Ajax Calls in Debug Mode gets response in text/plain from django and rest's xhr redirects it as it is not text/html. Please check code at following lines:

https://github.com/django/django/blob/stable/1.10.x/django/views/debug.py#L80

https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/static/rest_framework/js/ajax-form.js#L78

@tomchristie
Copy link
Member

tomchristie commented Aug 5, 2016

@anoopmalav - That makes sense, yup. Thanks. 👍

@tomchristie tomchristie added the Bug label Aug 9, 2016
@tomchristie tomchristie changed the title 500 error details not shown Traceback HTML not shown in browsable API Aug 10, 2016
@tomchristie
Copy link
Member

tomchristie commented Aug 10, 2016

@anoopmalav thanks for the comment there, very helpful when reviewing this! Good work folks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants