Loading Django template tag libraries using dotted notation
The template ta开发者_运维问答gs for an built using Django 1.1 organized within modules, like some_tags.py
below:
myproject
|__ __init__.py
|__ manage.py
|__ settings.py
|__ myapp
|__ __init__.py
|__ admin.py
|__ models.py
|__ templates
|__ templatetags
|__ __init__.py
|__ group1
|__ group2
|__ __init__.py
|__ some_tags.py
|__ views.py
|__ templates
|__ urls.py
And then to load those tags I could use {load group1.some_tags %}
. After porting the project to Django 1.2.5, those templates are generating errors (which are neatly solved by removing this load line). The module itself imports just fine from the shell, which is not the case when there's an error in the code.
The errors are:
ImportError: No module named group1
and
TemplateSyntaxError: Caught ImportError while rendering: No module named group1
Was support for dotted notation like this loading template tag libraries removed? I haven't seen anything in the release notes that would suggest this.
If this notation is no longer supported, what's a better alternative to organizing the template tag libraries without placing them all at the same file level?
精彩评论