How to put comments in Django templates?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Switch On Looping
--
Chapters
00:00 Question
00:20 Accepted answer (Score 413)
00:42 Answer 2 (Score 165)
01:07 Answer 3 (Score 32)
01:22 Answer 4 (Score 9)
01:50 Thank you
--
Full question
https://stackoverflow.com/questions/7199...
Answer 1 links:
https://docs.djangoproject.com/en/stable...
https://docs.djangoproject.com/en/stable...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #python3x #django #djangotemplates #djangocomments
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Switch On Looping
--
Chapters
00:00 Question
00:20 Accepted answer (Score 413)
00:42 Answer 2 (Score 165)
01:07 Answer 3 (Score 32)
01:22 Answer 4 (Score 9)
01:50 Thank you
--
Full question
https://stackoverflow.com/questions/7199...
Answer 1 links:
https://docs.djangoproject.com/en/stable...
https://docs.djangoproject.com/en/stable...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #python3x #django #djangotemplates #djangocomments
#avk47
ACCEPTED ANSWER
Score 434
As answer by Miles, {% comment %}...{% endcomment %} is used for multi-line comments, but you can also comment out text on the same line like this:
{# some text #}
ANSWER 2
Score 175
Comment tags are documented at https://docs.djangoproject.com/en/stable/ref/templates/builtins/#std:templatetag-comment
{% comment %} this is a comment {% endcomment %}
Single line comments are documented at https://docs.djangoproject.com/en/stable/topics/templates/#comments
{# this won't be rendered #}
ANSWER 3
Score 33
Using the {# #} notation, like so:
{# Everything you see here is a comment. It won't show up in the HTML output. #}
ANSWER 4
Score 9
This way can be helpful if you want to comment some Django Template format Code.
{#% include 'file.html' %#} (Right Way)
Following code still executes if commented with HTML Comment.
<!-- {% include 'file.html' %} --> (Wrong Way)