As far as i know all templatetag errors fail silently (true?) In any case im not getting an error, but i dont get this paragraph with The time is text either.
Just in case you need view code too - ill post it here. def index(request): if 'language' not in request.session: val = lang.objects.get(fdef=True).short request.session['language'] = val value = request.session['language'] lpl = lang.objects.get(short = value) langs = lang.objects.order_by('id') return render_to_response('front/arts.html', { 'lpl': lpl,'langs':langs }, context_instance=RequestContext(request)) Alan On May 1, 10:56 pm, Michael <newmani...@gmail.com> wrote: > On Fri, May 1, 2009 at 3:16 PM, zayatzz <alan.kesselm...@gmail.com> wrote: > > > Hello > > > In order to find more about django i proceeded to try creating > > templatetags. I decided to follow custom templatetag examples at > > djangoproject and djangobook (they are slightly different in both > > compliation and renderer part). > > > In any case the outcome is that the example described there does not > > work for me. I followed it step py step: > > > I had one app with one model, so i thought, lets add templatetags to > > this one, since it could benefit form it. > > I created templatetags folder and created __init__.py and arts_tag.py > > file in that folder. > > > This is the content of arts_tag.py file - pretty much 1 to 1 from > >http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ > > > from django import template > > import datetime > > > register = template.Library() > > > class CurrentTimeNode(template.Node): > > def __init__(self, format_string): > > self.format_string = format_string > > def render(self, context): > > return datetime.datetime.now().strftime(self.format_string) > > > def do_current_time(parser, token): > > try: > > # split_contents() knows not to split quoted strings. > > tag_name, format_string = token.split_contents() > > except ValueError: > > raise template.TemplateSyntaxError, "%r tag requires a > > single > > argument" % token.contents.split()[0] > > if not (format_string[0] == format_string[-1] and format_string[0] > > in > > ('"', "'")): > > raise template.TemplateSyntaxError, "%r tag's argument > > should be in > > quotes" % tag_name > > return CurrentTimeNode(format_string[1:-1]) > > > register.tag('current_time', do_current_time) > > > And i have this in my view : > > {% extends "front/index.html" %} > > > {% block arts %} > > > {% lorem 3 p %} > > {% load arts_tag %} > > <p>The time is {% current_time "%Y-%m-%d %I:%M %p" %}.</p> > > {% endblock %} > > > And it does not work. > > > Alan > > Hi Alan; > > Just glancing over this, I am not seeing any issues in this code. Maybe you > could paste the actual error that you are getting, it might help to pinpoint > where the problem is actually occurring. > > Thanks, > Michael --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---