Yes
TEMPLATE_DIRS = (
'home/escudero/projects_django/myproject/myapp/templatetags'
)
I have to change something in the TEMPLATE_LOADERS ?
On Fri, Apr 4, 2008 at 1:21 PM, Evert Rol <[EMAIL PROTECTED]> wrote:
>
> > Hmmm, I understand
> > Put the {% load current_time%} in the template, but I do not know
> > why, is looking in the wrong place.
> > "django.templatetags.current_time,"
> >
> > The right would be:
> > "myproject.myapp.templatetags.current_time"
> >
> > showing that error here:
> > TemplateSyntaxError at /myapp/
> > 'current_time' is not a valid tag library: Could not load template
> > library from django.templatetags.current_time, No module named
> > current_time
> >
> > somebody have any idea?
>
> Did you also set the TEMPLATE_DIRS correctly?
>
> > Hi,
> > I am having a problem creating tag, I do not know what I am forgetting
> >
> > You are showing that error here:
> > TemplateSyntaxError at /home/
> > Invalid block tag: 'current_time'
> >
> > somebody have any idea?
> > =/
> >
> > I do not see in your template where you {% load current_time %}
> > before trying to use the tag it registers. See:
> >
> >
> http://www.djangoproject.com/documentation/templates/#custom-tag-and-filter-libraries
> >
> > Karen
> >
> >
> > I have the files
> > ##################################################################
> > #### Template (teste.html):
> > {% current_time "%Y-%m-%d %I:%M %p" %}
> >
> > #### I created a model myapp ( myproject/myapp )
> > #### view.py
> > from django.shortcuts import render_to_response
> >
> > def home(request):
> > return render_to_response('teste.html')
> >
> > #### I create directory and file (myproject/myapp/templatetags/
> > current_time.py)
> > import datetime
> > from django.core import template
> > from django.core.template import Context, loader
> >
> > register = template.Library()
> >
> > def do_current_time(parser, token):
> > try:
> > # split_contents() knows not to split quoted strings.
> > tag_name, format_string = token.split_contents()
> > except ValueError:
> > msg = '%r tag requires a single argument' % token.contents[0]
> > raise template.TemplateSyntaxError(msg)
> > return CurrentTimeNode(format_string[1:-1])
> >
> > class CurrentTimeNode(template.Node):
> >
> > def __init__(self, format_string):
> > self.format_string = format_string
> >
> > def render(self, context):
> > now = datetime.datetime.now()
> > return now.strftime(self.format_string)
> >
> > register.tag('current_time', do_current_time)
> > #############################################################
> >
> > Only that.
> >
> > =/
> >
>
>
> >
>
--
Claudio Escudero
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---