Skip to content

Instantly share code, notes, and snippets.

@tyaslab
Created June 15, 2013 02:11
Show Gist options
  • Save tyaslab/5786503 to your computer and use it in GitHub Desktop.
Save tyaslab/5786503 to your computer and use it in GitHub Desktop.
more flexible django settings.py
import os
from django.conf import settings
PWD = os.path.dirname(os.path.dirname(__file__))
### ...
DATABASES = {
### ...
'NAME': os.path.join(PWD, 'databasename.db'), # Or path to database file if using sqlite3.
### ...
}
### ...
MEDIA_ROOT = os.path.join(PWD, 'media')
### ...
STATIC_ROOT = os.path.join(PWD, 'static')
### ...
TEMPLATE_DIRS = (
### ...
os.path.join(PWD, 'templates'),
)
### ...
INSTALLED_APPS = (
'yourmainapp', # Your main app should be the first to enable overriding
# ...
)
# ...
TEMPLATE_CONTEXT_PROCESSORS = settings.TEMPLATE_CONTEXT_PROCESSORS + (
'django.core.context_processors.request',
)
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment