#15525 closed Bug (fixed)
Custom template tags loading breaks whenever templatetags is a python file
| Reported by: | Omer Katz | Owned by: | Omer Katz |
|---|---|---|---|
| Component: | Template system | Version: | 1.2 |
| Severity: | Normal | Keywords: | templatetags |
| Cc: | omer.drow@… | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
Steps to recreate:
1) Create a django application.
2) Create an app.
3) In the app, instead of a templatetags folder create a templatetags.py.
4) Try to load it in the view.
The error:
'module' object has no attribute 'path'
Now, I know I shouldn't be doing that (But didn't know when I did it and it drove me nuts) but shouldn't this at least throw a less cryptic error message?
Attachments (1)
Change History (10)
comment:1 by , 15 years ago
| Cc: | added |
|---|
comment:2 by , 15 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
by , 15 years ago
| Attachment: | module_loading.patch added |
|---|
comment:3 by , 15 years ago
| Has patch: | set |
|---|
comment:4 by , 15 years ago
| Patch needs improvement: | set |
|---|
comment:5 by , 15 years ago
| Needs tests: | set |
|---|
comment:6 by , 15 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
Recreated the traceback in order to add a more specific error:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.2.5
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.flatpages',
'dojango',
'south',
'reversion',
'sitetree',
'tagging',
'paging',
'disqus',
'autoslug',
'django_generic_flatblocks',
'cms',
'blog',
'testtemplatetagserror']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'dojango.middleware.DojoCollector',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/generic/simple.py" in direct_to_template
17. t = loader.get_template(template)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in get_template
157. template, origin = find_template(template_name)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in find_template
134. source, display_name = loader(name, dirs)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in __call__
42. return self.load_template(template_name, template_dirs)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in load_template
48. template = get_template_from_string(source, origin, template_name)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader.py" in get_template_from_string
168. return Template(source, origin, name)
File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py" in __init__
158. self.nodelist = compile_string(template_string, origin)
File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py" in compile_string
186. return parser.parse()
File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py" in parse
282. compiled_result = compile_func(self, token)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader_tags.py" in do_extends
195. nodelist = parser.parse()
File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py" in parse
282. compiled_result = compile_func(self, token)
File "/usr/local/lib/python2.6/dist-packages/django/template/loader_tags.py" in do_block
173. nodelist = parser.parse(('endblock', 'endblock %s' % block_name))
File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py" in parse
282. compiled_result = compile_func(self, token)
File "/usr/local/lib/python2.6/dist-packages/django/template/defaulttags.py" in load
924. lib = get_library(taglib)
File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py" in get_library
1040. lib = import_library(taglib_module)
File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py" in import_library
992. if not module_has_submodule(app_module, taglib):
File "/usr/local/lib/python2.6/dist-packages/django/utils/module_loading.py" in module_has_submodule
17. for entry in package.__path__: # No __path__, then not a package.
Exception Type: AttributeError at /
Exception Value: 'module' object has no attribute '__path__'
Why does it break on:
nodelist = parser.parse(('endblock', 'endblock %s' % block_name))
And where does the try block begins and ends?
comment:7 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
Note:
See TracTickets
for help on using tickets.
Please improve the error to something along the lines of: "Unable to load template tags. templatetags must be a module but templatetags.py was probably found in %app_name%"