Rakibul Islam Prince
Rakibul Islam Prince

Reputation: 113

How to make multiple template tags work separately?

While working on a project on django , I came to a situation where I have to join four strings and also have to save the joined string in another variable. So, I made two custom template tag to do so. 1) for saving one data to another

@register.simple_tag
def save(value):
    return value

2)to join the strings

@register.simple_tag
def link(a,b,c,d):
    data=str(a)+","+str(b)+str(c)+","+str(d)
    return data

but when I am calling them from template like-

{% save link 14 12 2 3 as data %}

an error occurred saying--

'save' received too many positional arguments

that means they are overlapping each other. Now how to resolve this issue?

Upvotes: 0

Views: 295

Answers (1)

Manan M.
Manan M.

Reputation: 1394

Instead of using one template tag, you can use two tag line by line...

  • First one is for link function
  • Second is for save function

{% link 14 12 2 3 as data %} {% save data as value %}

Upvotes: 1

Related Questions