-
1 week 1 day
-
7 weeks 6 days
-
8 weeks 21 hours
-
9 weeks 6 days
-
10 weeks 2 days
Django: Setting template's path dynamically
I was trying Django the other night and the tutorial from their site mentioned to set the absolute directory to all of my template files on a variable called TEMPLATE_DIRS which is inside the settings.py.
Now I already read somewhere else that this is because you can specify your template files to be outside of your Django project. But for the sample I was working on, I want it to be inside the project's folder so I added a template folder there and to tell Django to automatically detect and set the path to my templates folder, I added it like this:
TEMPLATE_DIRS = ( os.path.join(os.getcwd(), "templates"), )
What this does is it joins the current directory where the settings.py file resides and concatenates it with the templates folder. You can probably put this inside a function when you start adding multiple template directories.

Facebook
Twitter
oh, I've been interested on
oh, I've been interested on this framework but I don't know more about python. I've been trying python and reading articles/tuts about it but theres always in my way, for example procastinating.Aynways, it's good that you've/you'll cover this framework. Nice.
Yeah, Django is cool. But it
Yeah, Django is cool. But it doesn't have the agnostic personality, but I like it though and falling in love with it each day.
Post new comment