...

Open source softwares - Django

Back to Course

Lesson Description


Lession - #1024 Django-Comment


Comments

Comments permits you to have segments of code that should be ignored.

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

Comment Description

You can add a message to your comment, to assist you with recalling why you wrote the comment, or as message to others perusing the code.
Example
<h1>Welcome Everyone</h1>
{% comment "this was the original welcome message" %}
    <h1>Welcome ladies and gentlemen</h1>
{% endcomment %}

Smaller Comments

You can likewise utilize the {# ... #} tags while commenting out code, which can be more straightforward when for more smaller comments:
Example:
Comment out the word Everyone:
<h1>Welcome{# Everyone#}</h1>

Comment in Views

Views are written in Python, and Python comments are composed with the # character:
Example:
Comment out 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(>
>