views:

45

answers:

1

Let's say I have a settings.py file in my app's root folder (/myapp/myapp/settings.py) with just a bunch of variables in it:

var1 = ''
var2 = ''

Can I automatically set one of those variables from the .ini file? I tried this:

myapp.settings.var1 = 'this is from development.ini'

But when I call var1 it is still the empty string:

import myapp.settings as s
print s.var1

I know that I can do var1 = config.get('myapp.settings.var1') in settings.py but that just doesn't seem as elegant to me :).

A: 

.ini is one way only communication. Django uses settings.py which is a normal python module that can be manipulated on-the-fly (causing many obscure errors). Setup your settings in .ini and use config.get to access variables.

iElectric
Django? Did you mean Pylons? I'm not using Django here.
swilliams
Pylons doesn't use settings.py.
Marius Gedminas