["python"]
Using Python's os.path, how do I go up one directory?

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/. 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.
os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'templates')) You can also use normpath to clean up the path, rather than abspath. However, in this situation, Django expects an absolute path rather than a relative path. For cross platform compatability, use os.pardir instead of '..'.