From f7d3c973c24fe8e82243c50b7c767ea709df711d Mon Sep 17 00:00:00 2001 From: sanj Date: Wed, 3 Mar 2010 20:16:56 +0530 Subject: [PATCH] updated settings to include local_settings --- itf/settings.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/itf/settings.py b/itf/settings.py index 1f10a58..9e8a479 100644 --- a/itf/settings.py +++ b/itf/settings.py @@ -76,7 +76,7 @@ MEDIA_URL = '/static/' ADMIN_MEDIA_PREFIX = '/admin/media/' # Make this unique, and don't share it with anybody. -SECRET_KEY = 'fognneiw#s_o-#^tiny@^f-$x#1&29$3a37w5=kll57i!^uo@r' +# SECRET_KEY = 'fognneiw#s_o-#^tiny@^f-$x#1&29$3a37w5=kll57i!^uo@r' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -123,3 +123,28 @@ INSTALLED_APPS = ( 'debug_toolbar', 'sorl.thumbnail', ) + +#overwrite default settings with local settings +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 = os.path.join(PROJECT_PATH, '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) + +