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:
[...] This post was mentioned on Twitter by KomunitasWeb, Django Ireland. Django Ireland said: Relative Path for your Django Project | KomunitasWeb http://bit.ly/baDGIN [...]