It worked.
=)

I removed ".core"

And fix the unicode thus:

     Def __init__ (self, format_string):
         Self.format_string = str (format_string)

Thanks,
Claudio Escudero
=)


On Fri, Apr 4, 2008 at 2:12 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:

> On Fri, Apr 4, 2008 at 12:35 PM, Claudio Escudero <[EMAIL PROTECTED]>
> wrote:
>
> >
> >
> > On Fri, Apr 4, 2008 at 1:23 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
> >
> > > Do you have an __init__.py file in your templatetags directory?
> > >
> > yes
> >
> > >
> OK, then current_time.py should be found for loading but if it is still
> failing there must be errors in the code.  You need to look carefully at the
> whole error message to see where the problems were encountered.  I tried
> your file and ran into a few problems, noted below.
>
>
> > [snipped extra stuff]
> > >
> > > >
> > > > > > 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
> > > > > >
> > > > >
> There should not be any '.core' in these two lines.  Fix them then the
> module will load, but you might hit an error below.
>
>
> > > > > > 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)
> > > > > >
> > > > >
> The argument to strftime will need to be cast to a string if you're
> running a recent (unicode-enabled) Django.
>
> Karen
>
>
> >
>


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

Reply via email to