- Author:
- ajs17
- Posted:
- February 28, 2007
- Language:
- Python
- Version:
- Pre .96
- Score:
- -3 (after 3 ratings)
In your site’s settings.py module (in your site root), TEMPLATE_DIRS takes absolute paths. Here is a way to dynamically determine the absolute path to the application directory so you only have to specify relative paths within settings.py. Obviously, replace “application_directory” with the name of your application’s directory.
1 2 3 4 5 | import os
dirname = os.path.dirname(globals()["__file__"])
TEMPLATE_DIRS = (
os.path.join(dirname, 'application_directory/templates'),
)
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 10 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
- Help text hyperlinks by sa2812 1 year, 6 months ago
Comments
I used to use the exact same code but then I discovered you can achieve the same by
#
Please login first before commenting.