Does django templates support functions?
Can I write them inline within the template?
If I can, how?
Does django templates support functions? Can I write them inline within the template? If
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. The idea of Django templates is that they only display information (more or less). More complicated constructs (like functions) must be defined elsewhere.
But, you can create your own template tags or template filters (in Python code) and then use them in your template. They kind of act like functions. Their definition is not within your template, though.
You can read about it in django documentation