views:

102

answers:

1

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
            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

+2  A: 
  1. 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
                              ...
    
  2. Did you registered the tag?

Example:

register = template.Library()   
@register.inclusion_tag('platform/templatetags/pagination_links.html')
def pagination_links(page, per_page, link):
maersu
Malcom.Z
Oh...Um...All right I've solved it finally. =.= You're right the templatetags folder should live in the app folder, after that I should change INSTALLED_APPS's settings in settings.py so that it can be properly placed in my project. After all, thanks for your help.
Malcom.Z