Andrew Tork Baker

Container and coffee enthusiast

Page 2

Using environment variables to keep sensitive data out of Django settings

I was helping a new developer at my company start developing with Django. As he was going through the Django Book he felt uncomfortable about storing secret keys, password, and API keys in his file. Environment variables are the solution, but I couldn’t find any good posts out there that explain the basics.

So here is how you use environment variables to keep sensitive data out of your source code:

  1. Set your environment variable using the export command, like this: export YOUR_SETTING_NAME=theSecretKey
  2. Add import os to your file if it isn’t there already.
  3. Retrieve the environment variable in your settings file with this syntax: EMAIL_HOST_PASSWORD = os.environ['DJANGO_EMAIL_PASSWORD']

Remember that the export command is specific to that terminal session. Your environment variable won’t be accessible from any other terminal windows, and it will disappear when...

Continue reading →

Hello blog

First posts are always hard to write, and not really useful for anything except filling out the first page. But, it’s a good opportunity to state for myself what I want this blog to be.

This blog should:

  1. Be a space I use to write about technology (my work and my side projects)
  2. Be a space I use to sometimes write about things other than technology
  3. Give me a kind of creative outlet I don’t have in my day job
  4. Be fun to work on

For now, this blog runs on [Pelican](, [reStructuredText](, and [Github pages](

In early 2014 I moved to Svbtle to make writing and publishing easier.

View →