I need to pass a user id to a template tag. After reading this: http://groups.google.com/group/django-users/ browse_thread/thread/96fe34b4561415dc/b7aba25f22bdd261? lnk=gst&q=template+tags+variable&rnum=1#b7aba25f22bdd261
I came up with: class SongListNode(template.Node): def __init__(self, artist, varname): self.artist, self.varname = artist, varname def __repr__(self): return "<Song Node>" def render(self, context): artist=self.artist.resolve(context) context[self.varname] = Song.objects.filter(artist=artist) #context[self.varname] = [self.artist] return '' class DoGetSongList: """ {% get_song_list as song_list %} """ def __init__(self, tag_name): self.tag_name = tag_name def __call__(self, parser, token): bits = token.contents.split() if len(bits) != 4: raise template.TemplateSyntaxError, "'%s' tag takes three arguments" % bits[0] if bits[2] != "as": raise template.TemplateSyntaxError, "second argument to '%s' tag must be 'as'" % bits[0] #return SongListNode(bits[1], bits[3]) return SongListNode(parser.compile_filter(bits[0]), bits[3]) register.tag('get_song_list', DoGetSongList('get_song_list')) But no love. Suggestions? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---