Wednesday, October 29, 2014

Re: Generating a list of available templates

Hi William,
 
for loader in settings.TEMPLATE_LOADERS:
    loader_module = importlib.import_module('.'.join(loader.split('.')[:-1]))
    print '\n'.join(source for source in loader_module.Loader().get_template_sources(''))

You could also get the loader like this:

from django.template.loader import find_template_loader
for loader_name in settings.TEMPLATE_LOADERS:
    loader
= find_template_loader(loader_name)
    loader
.get_template_sources('')  # etc

Collin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0113f972-5a48-4a88-bc84-79c435ae46c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment