trey (owner)

Forks

Revisions

gist: 134576 Download_button fork
public
Description:
Convenient things for settings.py
Public Clone URL: git://gist.github.com/134576.git
Python
1
2
3
4
5
6
7
8
9
10
11
12
# Reduce clutter in your settings.
 
def full_path(*parts):
    """Make an absolute path based on relation to this file"""
    return reduce(os.path.join, parts, os.path.dirname(os.path.abspath(__file__)))
 
# Call it like so:
 
TEMPLATE_DIRS = (
    full_path('templates'),
)
 
Python
1
2
3
4
5
6
7
8
9
10
# Hostname switching for easy to manage settings.
 
hostname = os.uname()[1].lower()
if hostname in ['localhost']:
    DATABASE_ENGINE = 'sqlite3'
    DATABASE_NAME = 'dev.db'
elif hostname in ['staging_server', 'something_else']:
    # Staging server settings
else:
    # Production server settings