I have a django app hosted on digitalocean with gunicorn and nginx.
I have just changed something in settings.py.

I have taken my SECRET_KEY and now I stored it in etc/secret_key.txt


with open('/etc/secret_key.txt') as f:
    SECRET_KEY = f.read().strip()

Do I have to restart anything in order to make the changes active?

How can I check if everything is working fine and settings.py can actually import from the txt-file?

Thx for help and stay healthy!

1 Answer 1


Django is a Python application that imports your configuration, which makes hot-reloading it near impossible. So yes, for changes to take effect, you'll need to restart the Django server.

Now in your case, your change doesn't actually change anything to the code once loaded (unless the content of the key changed as well), so you could ignore this particular reload if uptime is more important to you. However note that you should be very certain that your changes don't introduce an error otherwise it'll go unnoticed until the server reloads your app (eg. after a reboot) which might not start or do what you expect.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .