Wednesday, April 14, 2010

Django setting TEMPLATE_DIRS

Usually it would be done with something like:


import os
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
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.
os.path.join(CURRENT_DIR, "templates")
)

but on Windows the path is shown for instance as: C:\\path\\to\\dir...
(with "\\" for escaping), so the right setting of the templates directory would be something like:


import os
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIRS = (
os.path.join(CURRENT_DIR, "templates").replace('\\','/')
)

which will end as setting the TEMPLATE_DIRS for "current_dir_of_settings.py/templates".

No comments:

Categories

code (15) fun (2) linux (31) miscellaneous (9) music (8)

About me

I'm Adrian and this is my blog. Here I usually write about technical stuff (mostly about Linux).
Copyright: BY-NC_SA, Author: aeter