List Info

Thread: Include Template tags from application directory?




Include Template tags from application directory?
user name
2006-09-29 14:31:54
Hi all,
Here's a quick question from a newbie:
How do include template tags from within the application directory also?
I have TEMPLATE_DIRS = ( "path-to-my/templates/",) in my settings file
Importing templates is ok, but templatetags (which resides next
However, I get the error message:
"x is not a valid tag library: Could not load template library from django.templatetags.x"
 
Can someone give me some pointers?
 
Thanks,
Gareth

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users"; group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to django-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
Include Template tags from application directory?
user name
2006-09-29 14:41:07
On 9/29/06, DOUTCH GARETH-GDO003 <Gareth.Doutchmotorola.com> wrote:
>
> However, I get the error message:
> "x is not a valid tag library: Could not load
template library from
> django.templatetags.x"

Django will automatically discover any templatetags that you
have
defined, as long as they are contained within a
'templatetags'
directory in your model directory: e.g.,

myproject/
    myapp/
        __init__.py
        models.py
        templatetags/
            __init__.py
            mytemplatetags1.py
            mytemplatetags2.py

Where mytemplatetags[1,2].py are the 'tag libraries' -
collections of
template tags that are to be imported. If your template then
contains:

{% load mytemplatetags1 %}

any template tag registered in the 'mytemplatetags1' tag
library will
be visible to the template.

Hope this helps,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Include Template tags from application directory?
user name
2006-09-29 14:53:01
Thanks Russ, I was missing __init__.py in the templatetags
dir

Now I've got other error messages to fix ;) 

Gareth

-----Original Message-----
From: django-usersgooglegroups.com
[mailto:django-usersgooglegroups.com] On Behalf Of Russell
Keith-Magee
Sent: 29 September 2006 15:41
To: django-usersgooglegroups.com
Subject: Re: Include Template tags from application
directory?


On 9/29/06, DOUTCH GARETH-GDO003 <Gareth.Doutchmotorola.com> wrote:
>
> However, I get the error message:
> "x is not a valid tag library: Could not load
template library from 
> django.templatetags.x"

Django will automatically discover any templatetags that you
have
defined, as long as they are contained within a
'templatetags'
directory in your model directory: e.g.,

myproject/
    myapp/
        __init__.py
        models.py
        templatetags/
            __init__.py
            mytemplatetags1.py
            mytemplatetags2.py

Where mytemplatetags[1,2].py are the 'tag libraries' -
collections of
template tags that are to be imported. If your template then
contains:

{% load mytemplatetags1 %}

any template tag registered in the 'mytemplatetags1' tag
library will be
visible to the template.

Hope this helps,
Russ Magee %-)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )