I was wondering if it is better to import the variables into your view from the settings.py file? or is it better to create a configuration file with the necessary variables?
I like to write configuration files for my Django applications, read and import variables from there when necessary. For instance:
.configrc
[awesomeVariables] someMagicNumber = 7
views.py
from ConfigParser import SafeConfigParser
However, I noticed that some programmers prefer the following:
settings.py
SOME_MAGIC_NUMBER=7
views.py
import settings magicNumber = settings.SOME_MAGIC_NUMBER
I was curious about the pros and cons of different methods? Is it possible to import variables directly from your settings, violate the integrity of the architecture?
source share