Well, when I'm trying to use 'inclusion' in Django, I met some confused problems that I can't solve it by myself.
There is the structures for my project.
MyProject---
App1---
__init__.py
models.py
test.py
urls.py
views.py
App2---
...
template---
App1---
some htmls
App2---
...
templatetags---
__init__.py
inclusion_cld_tags.py
manage.py
开发者_JS百科 urls.py
__init__.py
settings.py
I have registered templatetags folder in the settings.py (Both in Installed APPS & TEMPLATE_DIRS). But when I want to use {% load inclusion_test %} in my html, it raise an exception like this:
'inclusion_cld_tags' is not a valid tag library: Could not load template library from django.templatetags.inclusion_cld_tags, No module named inclusion_cld_tags
I think there is nothing wrong with my import work, how can I do with that?
Thanks for help!
My django version: 1.0+ My Python version: 2.6.4
The templatetags folder should live in the app folder:
App1--- __init__.py models.py test.py urls.py views.py templatetags--- __init__.py inclusion_test.py ...
Did you registered the tag?
Example:
register = template.Library()
@register.inclusion_tag('platform/templatetags/pagination_links.html')
def pagination_links(page, per_page, link):
精彩评论