I'm sending out emails and I'd like to use HTML which is quite lengthy and currently in a file. What do people recommend doing as a way to reload it. The issue with local storage is that it might be costly to read from time wise. On the other hand including in a string/dictionary is possible but this is really messy. What is the recommended approach for storing say 10 HTML templates. I'd like to avoid a DB if I can.
Asked
Active
Viewed 336 times
2
-
while keeping the templates as files and setting up [cache](https://docs.djangoproject.com/en/dev/topics/cache/) properly, how long does it load? 100 slower than regular web page on the same server or worse? – Aprillion Jun 09 '14 at 19:49
1 Answers
2
Template caching could be a possible improvement here. You can cache the whole template by using a cached.Loader
or different template parts/fragments.
Also, consider using django-debug-toolbar
with a template-timings
panel to understand where the bottleneck is and where the time is spent:
Template-timings is a panel for Django Debug Toolbar that gives an in-dept breakdown of the time it takes to render your Django templates (including templates included via {% extends %} and {% include %}).

alecxe
- 462,703
- 120
- 1,088
- 1,195
-
does the cache will invalidate the cached template if the file is rewritten ? – FlogFR Jun 11 '14 at 08:37
-
@aRkadeFR I'm afraid it would not pick up the change until the cache is reseted, see also this [thread](http://stackoverflow.com/questions/4071221/resetting-cache-for-django-cached-template-loader). – alecxe Jun 11 '14 at 14:34