0 votes
1 view
in Python by (47.8k points)

I am new to Django-1.6. When I run the Django server with DEBUG = True, it's running perfectly. But when I change DEBUG to False in the settings file, then the server stopped and it gives the following error on the command prompt:

CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.

After I changed ALLOWED_HOSTS to ["http://127.0.0.1:8000",], in the browser I get the error:

Bad Request (400)

Is it possible to run Django without debug mode?

1 Answer

0 votes
by (107k points)

The ALLOWED_HOSTS list should contain fully qualified hostnames, not URLs. Leave out the port and the protocol. If you are using 127.0.0.1, I would add localhost to the list too:

ALLOWED_HOSTS = ['127.0.0.1', 'localhost']

You could also use * to match any host:

ALLOWED_HOSTS = ['*']

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...