Sometimes, we want to fix Python Django gives Bad Request (400) when DEBUG = False.
In this article, we’ll look at how to fix Python Django gives Bad Request (400) when DEBUG = False.
How to fix Python Django gives Bad Request (400) when DEBUG = False?
To fix Python Django gives Bad Request (400) when DEBUG = False, we set the ALLOWED_HOSTS
setting to allow the hosts we want.
For instance, we write
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
to set the ALLOWED_HOSTS
setting to an array of hosts that we allow to access our app.
We can allow all hosts with
ALLOWED_HOSTS = ['*']
Conclusion
To fix Python Django gives Bad Request (400) when DEBUG = False, we set the ALLOWED_HOSTS
setting to allow the hosts we want.