#25158 closed Bug (invalid)
InvalidTemplateLibrary when using django_extensions
| Reported by: | James Addison | Owned by: | nobody |
|---|---|---|---|
| Component: | Uncategorized | Version: | dev |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Trying to use django_extensions version 1.5.5 with Django master branch gives this traceback:
Environment:
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.9.dev20150721153804
Python Version: 3.4.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/utils.py" in __getitem__
86. return self._engines[alias]
During handling of the above exception ('django'), another exception occurred:
File "/Users/jaddison/.virtualenvs/django19test/lib/python3.4/site-packages/django_extensions/templatetags/highlighting.py" in <module>
41. from pygments import highlight as pyghighlight
During handling of the above exception (No module named 'pygments'), another exception occurred:
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/django.py" in get_package_libraries
144. module = import_module(entry[1])
File "/Users/jaddison/.virtualenvs/django19test/lib/python3.4/importlib/__init__.py" in import_module
109. return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/jaddison/.virtualenvs/django19test/lib/python3.4/site-packages/django_extensions/templatetags/highlighting.py" in <module>
45. raise ImportError("Please install 'pygments' library to use highlighting.")
During handling of the above exception (Please install 'pygments' library to use highlighting.), another exception occurred:
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/core/handlers/base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/jaddison/projects/django19test/testviews/views.py" in testview
5. return render(request, template)
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/shortcuts.py" in render
67. template_name, context, request=request, using=using)
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/loader.py" in render_to_string
91. template = get_template(template_name, using=using)
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/loader.py" in get_template
21. engines = _engine_list(using)
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/loader.py" in _engine_list
139. return engines.all() if using is None else [engines[using]]
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/utils.py" in all
110. return [self[alias] for alias in self]
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/utils.py" in <listcomp>
110. return [self[alias] for alias in self]
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/utils.py" in __getitem__
101. engine = engine_cls(params)
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/django.py" in __init__
31. options['libraries'] = self.get_templatetag_libraries(libraries)
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/django.py" in get_templatetag_libraries
49. libraries = get_installed_libraries()
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/django.py" in get_installed_libraries
131. for name in get_package_libraries(pkg):
File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/django.py" in get_package_libraries
148. "trying to load '%s': %s" % (entry[1], e)
Exception Type: InvalidTemplateLibrary at /
Exception Value: Invalid template library specified. ImportError raised when trying to load 'django_extensions.templatetags.highlighting': Please install 'pygments' library to use highlighting.
I'm not positive, but it looks like it will always blow up when a template tag 'library' is encountered that has missing Python dependencies - even if you don't use that library.
Change History (4)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
I guess it's related to this backwards incompatible change: https://docs.djangoproject.com/en/dev/releases/1.9/#template-tag-modules-are-imported-when-templates-are-configured
You should raise the issue with the library authors so they can update their packages or reopen this issue with more details about why this is a bug in Django. Thanks!
comment:3 by , 10 years ago
Ah, I missed that! I've raised issues in both django-extensions and django-pipeline - however, I do have to wonder how many packages will 'break' Django due to this, preventing many people from upgrading.
I assume that a break in the Django ecosystem is worth this change. :)
comment:4 by , 10 years ago
Well, if you have a non-functional library, I find it preferrable to crash at startup so you can notice and fix the issue, than randomly on pages that use the library.
Followup - I noticed this when trying to use django-pipeline version 1.5.2 as well.