Your local development server runs with the DEBUG = True setting.

On the live server, DEBUG is set to False.

Occasionally, you may wish to run the local server in live mode, with DEBUG = False 

A few steps are needed to achieve this.

Set some environment variables in the file .env-local:

DEBUG=False
STAGE=live

Gather static files to be served, using collectstatic. Run:

docker-compose run --rm web python manage.py collectstatic

Use the production web server (using uWSGI, and serving static files) rather than the Django runserver. In the docker-compose.yml file, change:

command: python manage.py runserver 0.0.0.0:80

to:

command: start web

Finally, restart the server.

Did this answer your question?