BEST SITE FOR WEB DEVELOPERS
Django. Lessons for beginners

Ua Es De

Django comment Tag


Comments

Comments allow you to have sections of code that should be ignored.

Example

<h1>Welcome Everyone</h1>
{% comment %}
  <h1>Welcome ladies and gentlemen</h1>
{% endcomment %}
Run Example »

Comment Description

You can add a message to your comment, to help you remember why you wrote the comment, or as a message to other people reading the code.

Example

Add a description to your comment:

<h1>Welcome Everyone</h1>
{% comment "this was the original welcome message" %}
    <h1>Welcome ladies and gentlemen</h1>
{% endcomment %}
Run Example »

Smaller Comments

You can also use the {# ... #} tags when commenting out code, which can be easier for smaller comments:

Example

Comment on the word Everyone:

<h1>Welcome{# Everyone#}</h1>
Run Example »

Comment in Views

Views are written in Python, and Python comments are written with the # character:

Example

Comment on a section in the view:

from django.http import HttpResponse
from django.template import loader

def testing(request):
  template = loader.get_template('template.html')
  #context = {
  # 'var1': 'John',
  #}
  return HttpResponse(template.render())
Run Example »

Read more about Python Comments in out Python Comment Tutorial.



Comments