kogakure (owner)

Fork Of

gist: 134576 by trey Convenient things for setti...

Revisions

gist: 135937 Download_button fork
public
Description:
Django: Convenient things for settings.py
Public Clone URL: git://gist.github.com/135937.git
Embed All Files: show embed
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