To work out what's gone wrong, you have to grep the Django source code for
`Bad Request`. Could there be a better way to communicate the cause of
the problem?
--
Ticket URL: <https://code.djangoproject.com/ticket/27760>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Tim Graham):
I think you can use the `manage.py test --debug-mode` option added in
#27008 to get the detailed exception page.
--
Ticket URL: <https://code.djangoproject.com/ticket/27760#comment:1>
Comment (by Peter Inglesby):
Running the test with `--debug-mode` does tell you what the problem is,
but it's only useful if you know that it exists, and even then it's not
obvious that it would help.
I've been poking around core/handlers/exception.py, and was able to get
the behaviour I'm after by adding
`signals.got_request_exception.send(sender=None, request=request)` to the
`SuspiciousOperation` branch of `response_for_exception`. Would this be a
viable approach?
--
Ticket URL: <https://code.djangoproject.com/ticket/27760#comment:2>
Comment (by Tim Graham):
A discussion on the DevelopersMailingList would be needed to see if
there's consensus to make a backwards-incompatible change there. The
current behavior is
[https://docs.djangoproject.com/en/dev/topics/testing/tools/#exceptions
documented]. The commit that introduced that signal is
f9cdde0cb41851e9d1eb70bd108debb75f267585.
--
Ticket URL: <https://code.djangoproject.com/ticket/27760#comment:3>
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Someday/Maybe
--
Ticket URL: <https://code.djangoproject.com/ticket/27760#comment:4>
Comment (by Petr Dlouhý):
To anyone bumping into this. I was able to determine the cause of the Bad
request by adding
{{{
@override_settings(
DEBUG=True,
)
}}}
decorator to the test class and then printing the response into file with
{{{
with open("response.html", "w") as f:
f.write(response.content.decode())
}}}
And the error was, that I hadn't test server url in `ALOWED_HOSTS`.
--
Ticket URL: <https://code.djangoproject.com/ticket/27760#comment:5>