Skip to content

Instantly share code, notes, and snippets.

@soulston
Created June 12, 2013 15:16
Show Gist options
  • Save soulston/5766202 to your computer and use it in GitHub Desktop.
Save soulston/5766202 to your computer and use it in GitHub Desktop.
Django absolute paths for settings.py (from https://snipt.net/kennethlove/django-absolute-paths-for-settingspy/)
import os
# here() gives us file paths from the root of the system to the directory
# holding the current file.
here = lambda * x: os.path.join(os.path.abspath(os.path.dirname(__file__)), *x)
PROJECT_ROOT = here("..")
# root() gives us file paths from the root of the system to whatever
# folder(s) we pass it starting at the parent directory of the current file.
root = lambda * x: os.path.join(os.path.abspath(PROJECT_ROOT), *x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment