When trying to generate templates with the mktemplate management command in a project with a project-level template directory, the command blows up when trying to access the template_dirs attribute on an instance of django.template.engine.Engine.
File "/home/haukur/Projects/neapolitan/src/neapolitan/management/commands/mktemplate.py", line 100, in handle
target_dir = Engine.get_default().template_dirs[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Engine' object has no attribute 'template_dirs'. Did you mean: 'template_loaders'?
I went digging around and found that template_dirs is an attribute of django.template.backends.base.BaseEngine.
I can only assume that there are some cases in which Engine.get_default() returns a subclass of BaseEngine instead of an instance of Engine.
I have a test project in a fork of Neapolitan that can be used to reproduce the error with
python manage.py mktemplate ice_cream.IceCream --list
I also have a branch in which I patched the mktemplate handle method to use the dirs property on Engine instead of the template_dirs property on BaseEngine if the latter is not present on the default engine. I'm not sure if that is always the correct behavior but it works on my machine (tm).
When trying to generate templates with the
mktemplatemanagement command in a project with a project-level template directory, the command blows up when trying to access thetemplate_dirsattribute on an instance ofdjango.template.engine.Engine.I went digging around and found that
template_dirsis an attribute ofdjango.template.backends.base.BaseEngine.I can only assume that there are some cases in which
Engine.get_default()returns a subclass ofBaseEngineinstead of an instance ofEngine.I have a test project in a fork of Neapolitan that can be used to reproduce the error with
I also have a branch in which I patched the
mktemplatehandlemethod to use thedirsproperty onEngineinstead of thetemplate_dirsproperty onBaseEngineif the latter is not present on the default engine. I'm not sure if that is always the correct behavior but it works on my machine (tm).