While you cannot use Python operators and functions directly in the templates, you can write your own "wrappers" around those you need:
On Wednesday, 27 May 2020 15:57:34 UTC+2, Daniel Roseman wrote:
-- On Wednesday, 27 May 2020 15:57:34 UTC+2, Daniel Roseman wrote:
On Wednesday, 27 May 2020 13:21:24 UTC+1, ratnadeep ray wrote:Hi all,Currently I am trying to print the type of a variable from the Django template html file as follows:<center><h2>The type of feature list report for version {%type(version)%} is<h2></center>For the above, I am getting the following error:Invalid block tag on line 9: 'type(version)'. Did you forget to register or load this tag?So what's going wrong here? How can we use the python related api's (like type) from the html template files? I think inside the {% .... %} we can use python related evaluations. Am I right?Please throw some lights on this .Thanks.No, you are wrong, and this is explicitly pointed out in the docs (https://docs.djangoproject.com/en/3.0/ref/templates/ ):language/ > bear in mind that the Django template system is not simply Python embedded into HTML. This is by design: the template system is meant to express presentation, not program logic.--DR.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/09e739dd-60c8-4360-9f9f-d3270c7901ca%40googlegroups.com.
No comments:
Post a Comment