Sunday, April 26, 2020

Abhijeet Pal: Using Environment Variables In Django

While working with web applications often we need to store sensitive data for authentication of different modules such as database credentials and API keys. These sensitive keys should not be hardcoded in the settings.py file instead they should be loaded with Environment variables on runtime. An environment variable is a variable whose value is set outside the program, typically through a functionality built into the operating system. An environment variable is made up of a name/value pair. Environment variables help us keep secrets (for example, Passwords, API tokens, and so on) out of version control, therefore, they are considered an integral part of the popular Twelve-Factor App Design methodology and a Django best practice because they allow a greater level of security and simpler local/production configurations. Also, environment variables provide a greater degree of flexibility for switching between local development setup and production setup. Therefore Adding environment variables is a necessary step for any truly professional Django project. Creating Environment Variables Create a .env file in the same directory where settings.py resides and add the following key-value pair inside the …

The post Using Environment Variables In Django appeared first on Django Central.



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...