nickjj / docker-django-example

A production ready example Django app that's using Docker and Docker Compose.
MIT License
1.17k stars 249 forks source link

Getting Server Error (500) on debug=false on env file #6

Closed pramishp closed 3 years ago

pramishp commented 3 years ago

thank you for this excellent docker django example. I am getting 500 on setting debug=false in env file

image

nickjj commented 3 years ago

Hi,

After setting that value did you run a docker-compose build before upping it?

nickjj commented 3 years ago

Ah I know what happened.

If you're going to set DEBUG=false you also need to set NODE_ENV=production. If you don't set node to production then Django's collectstatic won't find any assets since they won't get generated by Webpack and when you visit the home page you'll get a 500 which throws ValueError: Missing staticfiles manifest entry for 'css/app.css' because our template references that file.

You can find the real cause of the 500 with DEBUG=false if you goto the settings and put DEBUG_PROPAGATE_EXCEPTIONS = True.

To properly emulate production on a real server you'll want to run:

Now it should work.

It's really important to run the build command because that's going to ensure collectstatic gets run.

nickjj commented 3 years ago

I'm going to close this one since the above is very likely the case. Feel free to re-open it if it's not.