Django custom template tag passing variable number of arguments?

You can pass any number of variables to your custom template tag by using Python's built in way of passing in multiple values from a list. Example: from django import template register = template.Library() @register. Tag('my_tag') def do_whatever(parser, token): bits = token.contents.split() """ Pass all of the arguments defined in the template tag except the first one, which will be the name of the template tag itself.

Example: {% do_whatever arg1 arg2 arg3 %} *bits1: would be: arg1, arg2, arg3 """ return MyTemplateNode(*bits1:) class MyTemplateNode(template. Node): def __init__(self, *args, **kwargs): do_something() def render(self, context): do_something_else() Hope that helps you out.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions