Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to comment out python code in a django html file?

I'm curious, i have the following code {% code_goes_here %}, how do I comment it out in the html file?

like image 250
locoboy Avatar asked Dec 27 '22 11:12

locoboy


2 Answers

Django templates has {# ... #} as comments. NOTE: These comments are not multi-line.

like image 109
Some programmer dude Avatar answered Jan 18 '23 23:01

Some programmer dude


There are multiple ways to comment in templates as other people have mentioned in their answers, so I thought I'll quickly summarize them below:

As brc mentioned above, you could use HTML comments <!-- --> but the comment would show if the user views the source of the page.

For single line comments in templates, use: {# ... #}

For multi-line comments in templates, use:

{% comment %}
{% code_goes_here %}
{% endcomment %}
like image 34
Anupam Avatar answered Jan 18 '23 22:01

Anupam