Answer the question
In order to leave comments, you need to log in
How to access variable or functions from html template?
I just started learning django and I couldn't find anything in the documentation or on the internet.
I know that I can access a variable or function by putting it in views.py and sending it to
return render(request, 'html.html', {'args':args })
<!--для переменных-->
<div>
{% load TEST %}
TEST
</div>
<!--для функций -->
<div>
{% load TEST %}
TEST(1,2)
</div>
<!--для списков-->
<div>
{% load TEST %}
TEST[0]
</div>
Answer the question
In order to leave comments, you need to log in
1. Write your own context processors https://docs.djangoproject.com/en/3.1/ref/template...
2. You can't explicitly call functions in the template, just write your own tag or filter https://docs.djangoproject.com /en/3.1/howto/custom...
3. In the template, lists can be accessed asTEST.0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question