The Great Magnet. What a fool I was to defy him.

Django — Setting DJANGO_SETTINGS_MODULE / Environment Variables from Python

November 13, 2008 · Leave a Comment

You know, I learned this and completely forgot after months of not dealing with it. Google searches are so difficult to reach the right subject.

I’m certain this will be something I refer to in the future..

Setting environment variables via Python is as simple as:

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

Of course, this doesn’t permanently set the variable, but if you have a script that needs that envvar, perfect.

Enjoy.

Categories: Django · Python

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment