custom template tags and template loaders

72 views
Skip to first unread message

chefsmart

unread,
Jul 28, 2009, 4:23:33 PM7/28/09
to Django users
Is 'django.template.loaders.app_directories.load_template_source'
required in the TEMPLATE_LOADERS setting for custom template tags to
work?

krylatij

unread,
Jul 29, 2009, 3:45:37 AM7/29/09
to Django users
No, this settings
'django.template.loaders.app_directories.load_template_source'
means, that django will look for templates( not tags ) in each(!)
application you have in INSTALLED_APPS
(if application folder has folder 'templates' ).

chefsmart

unread,
Jul 29, 2009, 5:09:09 AM7/29/09
to Django users
I am using the smart_if templatetag from http://www.djangosnippets.org/snippets/1350/
but when i remove the
'django.template.loaders.app_directories.load_template_source' this
custom templatetag stops working.

I am pretty sure this loader is being used for templatetags as well.

krylatij

unread,
Jul 29, 2009, 10:25:51 AM7/29/09
to Django users
I my case custom tags are still working after i removed
''django.template.loaders.app_directories.load_template_source'' from
settings.
You can see comment in site-packages\django\template\loaders
\app_directories.py:
"""
Wrapper for loading templates from "templates" directories in
INSTALLED_APPS
packages.
"""

Please post exception you get.

chefsmart

unread,
Jul 29, 2009, 10:44:11 AM7/29/09
to Django users
I get the following message. Please note that everything is ok in my
development setup, but the same thing doesn't work in my production
setup.


TemplateSyntaxError at /staff/

'smart_if' is not a valid tag library: Could not load template library
from django.templatetags.smart_if, No module named smart_if

Request Method: GET
Request URL: http://www.xxxxxxxxxxx.org/staff/
Exception Type: TemplateSyntaxError
Exception Value:

'smart_if' is not a valid tag library: Could not load template library
from django.templatetags.smart_if, No module named smart_if

Exception Location: /home/kdjfiownf/webapps/drf_app/lib/python2.5/
django/template/defaulttags.py in load, line 927

krylatij

unread,
Jul 29, 2009, 12:24:38 PM7/29/09
to Django users
And what about other custom tags?
I actually have no more ideas, what it can be.

chefsmart

unread,
Jul 29, 2009, 3:06:20 PM7/29/09
to Django users
I got no other custom tags. This is pretty confusing. It works
perfectly on the django dev server with no code changes.

Don't really know enough about the pre-requisites (settings.py, etc)
for using custom templatetags, so haven't progressed much in my
troubleshooting.

krylatij

unread,
Jul 30, 2009, 1:49:01 AM7/30/09
to Django users
And do you want to avoid
'django.template.loaders.app_directories.load_template_source' ?

It will work only when your template will not be found in default
template directory
So i guess there is no overhead when you use it in production.

May be you have DEBUG=True in your development version and
DEBUG=False in production. So it can be the reason.

chefsmart

unread,
Jul 30, 2009, 3:11:45 AM7/30/09
to Django users
There is absolutely no difference between my dev and production, only
the database details in the settings.py are different.

The 'django.template.loaders.app_directories.load_template_source' is
not included in both my dev as well as my production setups (which is
in testing phase now).

So since there is essentially no difference between the two setups, I
am guessing the error is because of the pre-requisites. Sadly I don't
know what those are to be effective in my troubleshooting.

chefsmart

unread,
Jul 30, 2009, 4:00:24 AM7/30/09
to Django users
Daymien has a similar issue at http://groups.google.com/group/django-users/t/7b7dad85530eceed

Just wanted to link the two discussions.

Daymien

unread,
Jul 30, 2009, 4:40:59 AM7/30/09
to Django users
Reply all
Reply to author
Forward
0 new messages