Wednesday, March 30, 2011

django custom template tags: how to send to (parser, token)

I've just started using custom tags and need some help parsing info

def friends_of(parser, token):
tag_name, user_var = token.split_contents()
return FriendsOfNode(user_var)

class FriendsOfNode(template.Node):
def __init__(self, user_var):
self.user_var = template.Variable(user_var)

def render(self, context):
user = self.user_var.resolve(context)
context.update({'friends': Friendship.objects.friends_of(user,
return u''

I tried:

friends: {% friends_of {{ user }} %}


ValueError at /friends/

too many values to unpack

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment