1

in template

{{object.get_resource}}

in views.py(DetailView)

def get_resource(self):
    return "my resource"

It works.

Now, I want to pass the variable to object.

Is it possible to do like this below?

{{object.get_resource(1)}}

def get_resource(self,num):
    return "my resource:{0}".format(num)

1 Answer 1

3

Sadly, you cannot pass arguments to functions in Django templates.

You ought to write your own template tags.

Use this answer as reference :-)

Sign up to request clarification or add additional context in comments.

1 Comment

I see. I will find the workaround, but thank you very much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.