When using the django.template.loaders.cached.Loader template loader (which is enabled by default whenever DEBUG is off and which is explicitly set to be on in the base settings of my project), you get this error trying to view the styleguide root page:
AttributeError at /styleguide/
'Loader' object has no attribute 'get_template_sources'
for template_dir in loader.get_template_sources('styleguide'):
The problem is that the cached loader doesn't have a get_template_sources method. The loaders that it wraps do, and those can be accessed via its loaders attribute, but it itself does not. (This is true at least in Django 1.8, which is what this project currently uses.)
So I guess we need to find some more robust way to find the styleguide templates. One approach would be to just check whether there's a loaders value to iterate over and use those. Another might be to do something inspired by what get_app_template_dirs does.
When using the
django.template.loaders.cached.Loader
template loader (which is enabled by default wheneverDEBUG
is off and which is explicitly set to be on in the base settings of my project), you get this error trying to view the styleguide root page:The error is happening here:
The problem is that the cached loader doesn't have a
get_template_sources
method. The loaders that it wraps do, and those can be accessed via itsloaders
attribute, but it itself does not. (This is true at least in Django 1.8, which is what this project currently uses.)So I guess we need to find some more robust way to find the styleguide templates. One approach would be to just check whether there's a
loaders
value to iterate over and use those. Another might be to do something inspired by whatget_app_template_dirs
does.