load local_settings.py

This commit is contained in:
j 2013-02-12 13:25:14 +05:30
parent f157b4bd49
commit c127fecd41

View file

@ -84,9 +84,6 @@ STATICFILES_FINDERS = (
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'gm!%-n#6$=hah**x9k9-%4dya$3-(q&4bowca+c24y3dijjd7i'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
@ -155,3 +152,28 @@ LOGGING = {
},
}
}
#load installation specific settings from local_settings.py
try:
from local_settings import *
except ImportError:
pass
# Make this unique, creates random key first at first time.
try:
SECRET_KEY
except NameError:
SECRET_FILE = join(PROJECT_ROOT, 'secret.txt')
try:
SECRET_KEY = open(SECRET_FILE).read().strip()
except IOError:
try:
from random import choice
SECRET_KEY = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
secret = file(SECRET_FILE, 'w')
secret.write(SECRET_KEY)
secret.close()
except IOError:
Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE)