I recently upgrade Django from v1.3.1 to v1.4.
In my old settings.py
I have
TEMPLATE_DIRS = (
os.path.join(os.path.dirname( __file__ ), 'templates').replace('\\', '/'),
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
This will point to /Users/hobbes3/Sites/mysite/templates
, but because Django v1.4 moved the project folder to the same level as the app folders, my settings.py
file is now in /Users/hobbes3/Sites/mysite/mysite/
instead of /Users/hobbes3/Sites/mysite/
.
So actually my question is now twofold:
- How do I use
os.path
to look at a directory one level above from__file__
. In other words, I want/Users/hobbes3/Sites/mysite/mysite/settings.py
to find/Users/hobbes3/Sites/mysite/templates
using relative paths. - Should I be keeping the
template
folder (which has cross-app templates, likeadmin
,registration
, etc.) at the project/User/hobbes3/Sites/mysite
level or at/User/hobbes3/Sites/mysite/mysite
?
os
tocd
to../mysite
? Or whatever command you want – prelicsettings.py
in multiple servers. The only difference might be the database credentials. I was reading theos.path
documentation but I couldn't find a command that let's you go up one directory. Likecd ..
. – hobbes3os.path.join( os.path.dirname( __file__ ), '..' )
..
means the directory above throughout the filesystem, not just when passed tocd
. – Michael Berkowskios.path.join( os.path.dirname ( __file__), os.path.pardir)
– mgilson