From 1174541d45e4ef8923a0965eb650ace5d74c6fcc Mon Sep 17 00:00:00 2001 From: sanj Date: Tue, 2 Mar 2010 22:51:03 +0530 Subject: [PATCH] include local_settings in settings --- index/settings.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/index/settings.py b/index/settings.py index 8047c6e..791a739 100644 --- a/index/settings.py +++ b/index/settings.py @@ -54,8 +54,6 @@ LOGIN_REDIRECT_URL = '/' # Examples: "http://foo.com/media/", "/media/". ADMIN_MEDIA_PREFIX = '/admin/media/' -# Make this unique, and don't share it with anybody. -SECRET_KEY = ')o1)c68=b9k5z@af=_@s31)pcp58yxo@5@$b5!^_vlijibziq1' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -90,3 +88,27 @@ INSTALLED_APPS = ( 'tagging', 'south', ) + +#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) +