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. Effective content caching for mass-load site using redirect feature by nnseva 1 year, 10 months ago
  2. FirstRun Middleware by TheMysteriousX 2 years ago
  3. djangopath: conveniently set sys.path and DJANGO_SETTINGS_MODULE by alia_khouri 4 years, 9 months ago
  4. X-Sendfile static file serve view by dokterbob 2 years, 7 months ago
  5. Automagically import settings from installed applications by jezdez 5 years, 3 months ago

Comments

(Forgotten your password?)