4

I have a Django application where all the secret information (secret key and keys for encryption) are in the .env file as environment variables - I'm using the python-dotenv library. After starting the application, I removed the .env file from the server files and the application continues to work as it should. Can deleting this file cause any problems? Is there any other (or better) way to secure these secrets in a Django application? If it's relevant, I use pythonanywhere.com

1 Answers1

1

You shouldn't need .env file if you instead set up Environment variables while initialising the server machine.

Many Cloud Service Providers let you do that. If you're setting up a docker container in Google App run, you should be able to setup environment variables or when setting up virtual machine with predetermined environment variables.

This should eliminate any requirement for having .env file.

Anurag Dhadse
  • 1,722
  • 1
  • 13
  • 26
  • What about trying to run your application locally for testing? This makes sense when you deploy your application to production, but what is the alternative to using a dot ENV file locally? – Pants Jun 06 '23 at 16:17
  • IDE's also support environment variables via build configurations or run configurations. – Anurag Dhadse Jun 07 '23 at 09:48