From c127fecd41091049249d4beaf06e878fec13134a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 12 Feb 2013 13:25:14 +0530 Subject: [PATCH] load local_settings.py --- pdfvideo/settings.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/pdfvideo/settings.py b/pdfvideo/settings.py index a9eb55f..a111647 100644 --- a/pdfvideo/settings.py +++ b/pdfvideo/settings.py @@ -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) +