return os.path.join(os.path.dirname(__file__), directory_name).replace('\\', '/')
STATIC_ROOT = map_path('static')
TEMPLATE_DIRS = map_path('templates')
This would find the "static" and "templates" directories (given the structure below) without having to hard code the paths in settings.py. This is very useful if you switch environments from Windows to Mac or Linux from say a PC workstation at your office to a Mac at home.
Example Directory Structure: