Friday, November 20, 2009

Django properties for settings.py

I wanted to externalize all of the properties in settings.py for obvious reasons. I found a couple of suggestions.

What I did was create to files, properties_local.py and properties_dev.py. Working locally I imported, "import properties_local as properties"
# Django settings for [project name] project.
import properties_local as properties

and then set the variables accordingly:
DATABASE_ENGINE = properties.DATABASE_ENGINE
DATABASE_NAME = properties.DATABASE_NAME
DATABASE_USER = properties.DATABASE_USER
DATABASE_PASSWORD = properties.DATABASE_PASSWORD
DATABASE_HOST = properties.DATABASE_HOST
DATABASE_PORT = properties.DATABASE_PORT
I only have to change the import setting. I should figure out a way around that soon though.

No comments: