Sometimes you need to move your Django project (example:from local computer to production server) or you work as a team which don’t have the same path to your project. If you give absolute path then you always need to change the settings.py.
The trick is to give relative path to your project.
TEMPLATE_DIRS = ( # 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. )
While the sample settings said you need to add absolute path, I’d prefer to use relative path.
# settings.py import os PROJECT_PATH = os.path.realpath(os.path.dirname(__file__)) TEMPLATE_DIRS = ( os.path.join(PROJECT_PATH, 'templates') )
That’s it. Have fun!
Related posts:
- Django Tutorial – Simple Notes Application
- Using Django template in PHP
- How to Check if An Application is Installed in Django
- Open Atrium, Open Source Project Management Software with Beauty in Mind
- Set Different Settings for Development in Django
June 29th, 2010 | Comments(3)

[...] This post was mentioned on Twitter by KomunitasWeb, Django Ireland. Django Ireland said: Relative Path for your Django Project | KomunitasWeb http://bit.ly/baDGIN [...]
Pingback by Tweets that mention Relative Path for your Django Project | KomunitasWeb -- Topsy.com — June 29, 2010 @ 9:37 am
New blog posting, Relative Path for your Django Project – http://tinyurl.com/22qjkx7
This comment was originally posted on Twitter
Comment by komunitasweb — June 29, 2010 @ 6:21 am
Relative Path for your Django Project | KomunitasWeb http://bit.ly/baDGIN
This comment was originally posted on Twitter
Comment by DjangoIreland — June 29, 2010 @ 9:09 am