From fd3a5dffc3509912213dcb87638393d0e907e399 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 8 Dec 2011 02:52:03 +0530 Subject: [PATCH] settings stuff --- manifests/settings.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/manifests/settings.py b/manifests/settings.py index 8b4200d..87956f5 100644 --- a/manifests/settings.py +++ b/manifests/settings.py @@ -63,8 +63,23 @@ MEDIA_URL = '/static/' # Examples: "http://foo.com/media/", "/media/". ADMIN_MEDIA_PREFIX = '/media/' -# Make this unique, and don't share it with anybody. -SECRET_KEY = '#7w*kxhnvpvq)v0fj(%1+rqphvzmjp%i9xfi=4&%*3!*&(b#v2' +# Make this unique, creates random key first at first time. +try: + SECRET_KEY +except NameError: + SECRET_FILE = os.path.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) + # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -102,3 +117,8 @@ INSTALLED_APPS = ( # Uncomment the next line to enable admin documentation: 'django.contrib.admindocs', ) + +try: + import local_settings +except: + pass