On 1/4/07, stoKes <[EMAIL PROTECTED]> wrote:
On Jan 4, 12:10 pm, "Jorge Gajon" <[EMAIL PROTECTED]> wrote:
> Hi Adam,
>
> On 1/3/07, stoKes <[EMAIL PROTECTED]> wrote:
>
> > base.html
> > {% showmenu %}
> > {% for service in services %}
> > <li><a href="/toolbox/{{ service.name }}/">{{
> > service.name }}</a></li>
> > {% endfor %}
>
> > but receiving this error:
>
> > Exception Type: TemplateSyntaxError
> > Exception Value: Invalid block tag: 'showmenu'Try putting {% load
showmenu %} before the call to the tag, for example:
>
> {% load showmenu %}
> {% showmenu %}
> {% for service in services %}
> <li><a href="/toolbox/{{ service.name }}/">{{service.name }}</a></li>
> {% endfor %}
>
> The {% load %} tag loads a .py file that contains your custom tags. In
> this case it will try to load the file
> /project/templatetags/showmenu.py
>
> If the .py file with your custom tags had a different name, for
> example "mytags.py" then you would need to type a {% load mytags %} in
> your template before using your custom tags.
>
Hey Jorge,
I had tried that, however, this is the error I got :
Exception Type: TemplateSyntaxError
Exception Value: 'showmenu' is not a valid tag library: Could not load
template library from django.templatetags.showmenu, No module named
showmenu
i've created other templatetags before that loaded perfectly if i did
it for a certain app, for example,
/project/myapp/templatetags/tag.py
but this is more of a global template tag so im not sure if my
procedure in doing this is correct or not
Oh I didn't noticed that little detail. But no, you can't have a
"global" templatetag, your custom tags must be inside the
'templatetags' folder inside your app. This is what the documentation
says about it:
"""The {% load %} tag looks at your INSTALLED_APPS setting and only
allows the loading of template libraries within installed Django apps.
This is a security feature: It allows you to host Python code for many
template libraries on a single computer without enabling access to all
of them for every Django installation.
If you write a template library that isn't tied to any particular
models/views, it's perfectly OK to have a Django app package that only
contains a templatetags package."""
Hope it helps
Regards,
Jorge
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---