mjumbewu / django-jstemplate

Embed Javascript templates (mustache.js and more) into Django templates with minimal fuss.
Other
41 stars 16 forks source link

Fix incompatibility with the latest versions of django-debug-toolbar #9

Closed Psycojoker closed 9 years ago

Psycojoker commented 9 years ago

Hello,

In the latest version of django debug toolbar, it is recommended to add this entry the INSTALLED_APPS:

debug_toolbar.apps.DebugToolbarConfig

Which is not a django module. This conflict with the way django-jstemplate parses the INSTALLED_APPS tuple and results in this exception (cut because it is terribly long):

  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/django/template/base.py", line 1336, in get_library
    lib = import_library(taglib_module)
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/django/template/base.py", line 1270, in import_library
    mod = import_module(taglib_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/jstemplate/templatetags/jstemplate.py", line 3, in <module>
    from .rawjstemplate import rawjstemplate
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/jstemplate/templatetags/rawjstemplate.py", line 2, in <module>
    from .base import BaseJSTemplateNode, jstemplate_tag_helper
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/jstemplate/templatetags/base.py", line 6, in <module>
    from ..loading import find, preprocess, JSTemplateNotFound
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/jstemplate/loading.py", line 80, in <module>
    finders = _get_finders()
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/jstemplate/loading.py", line 72, in _get_finders
    return _get_classes(conf.JSTEMPLATE_FINDERS)
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/jstemplate/loading.py", line 55, in _get_classes
    mod = import_module(modpath)
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/django/utils/importlib.py", line 46, in import_module
    __import__(name)
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/jstemplate/finders.py", line 125, in <module>
    app_template_dirs = _get_app_template_dirs()
  File "/home/psycojoker/code/django/vegout/ve/lib/python2.7/site-packages/jstemplate/finders.py", line 112, in _get_app_template_dirs
    raise ImproperlyConfigured("ImportError %s: %s" % (app, e.args[0]))
ImproperlyConfigured: ImportError debug_toolbar.apps.DebugToolbarConfig: No module named DebugToolbarConfig

Apparently, django-jstemplate is not the first django application to have this problem has you can see here for haystack: https://github.com/toastdriven/django-haystack/issues/1074 which has been fixed this way: https://github.com/toastdriven/django-haystack/commit/a32c8993ae986fe22d362d477b434b39b13a2cc6

I have taken a similar approach in this pull request.

Kind regards and thanks for your work :)

mjumbewu commented 9 years ago

Thanks!