Get project name

1,849 views
Skip to first unread message

Alessandro Ronchi

unread,
Aug 21, 2009, 2:31:19 PM8/21/09
to django...@googlegroups.com
Is there any way to get the project name that's running in the code?

Now I use a manual setting: PROJECT_NAME = "ambiente"
but it should be useful to avoid that, because I'm working on an
external app and every new unuseful configuration simplify my life a
lot.

--
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com

Bill Freeman

unread,
Aug 21, 2009, 3:56:49 PM8/21/09
to django...@googlegroups.com
Alessandro,

In settings.py:

import os.path
PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
PROJECT_NAME = os.path.basename(PROJECT_ROOT)

Then, in modules where you need it:

from django.conf import settings

PROJECT_NAME = settings.PROJECT_NAME

Bill
Reply all
Reply to author
Forward
0 new messages