How to put comments in Django templates

后端 未结 6 1231
清歌不尽
清歌不尽 2020-12-04 07:46

I would like to comment this with a line

{% if something.property %}
    ...



{% # this is a comment %}
{% if something.pr         
6条回答
  •  日久生厌
    2020-12-04 08:53

    In contrast to traditional html comments like this:

    
    

    Django template comments are not rendered in the final html. So you can feel free to stuff implementation details in there like so:

    Multi-line:

    {% comment %}
        The other half of the flexbox is defined 
        in a different file `sidebar.html`
        as 

    Single line:

    {# jquery latest #}
    
    {#
        beware, this won't be commented out... 
        actually renders as regular body text on the page
    #}
    

    I find this especially helpful for views that have not been created yet.

提交回复
热议问题