easy absolute path for settings.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import os
#ROOT : the django proyect root
ROOT = lambda base : os.path.join(os.path.dirname(__file__), base).replace('\\','/')

#usage examples

DATABASE_NAME = ROOT('data/mydb.db')

TEMPLATE_DIRS = (
    ROOT('templates'),
)

#...

More like this

  1. Dynamically specify TEMPLATE_DIRS by ajs17 5 years, 2 months ago
  2. set_paths by amitu 3 years, 7 months ago
  3. djangopath: conveniently set sys.path and DJANGO_SETTINGS_MODULE by alia_khouri 3 years, 9 months ago
  4. FirstRun Middleware by TheMysteriousX 1 year ago
  5. Paths in Django settings relative to settings.py by zejn 4 years, 7 months ago

Comments

(Forgotten your password?)