Skip to content

Instantly share code, notes, and snippets.

@kunanit
Created March 20, 2016 00:55
Show Gist options
  • Save kunanit/bf1e2c915b34b320b5c0 to your computer and use it in GitHub Desktop.
Save kunanit/bf1e2c915b34b320b5c0 to your computer and use it in GitHub Desktop.
local settings file for a django project
'''
creates local settings for a django project
- define secret key
- use a local sqlite3 database
reference: http://stackoverflow.com/questions/4909958/django-local-settings
'''
import os
os.environ['SECRET_KEY'] = 'mysecretkey'
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
## put the following at the end of the settings.py file:
'''
try:
from local_settings import *
except ImportError:
pass
SECRET_KEY = os.environ['SECRET_KEY']
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment