🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Django Notes
Topic #33

Django Comment


Comments

Comments allows you to have sections 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 help you remember why you wrote the comment, or as message to other people reading 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 also use the {# ... #} tags when commenting out code, which can be easier for smaller comments:

Example

<h1>Welcome{# Everyone#}</h1>

Comment in Views

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

Example

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())

Read more about Python Comments in out Python Comment Tutorial.

Want to go beyond the notes?

Join CodingNow 2.0's Django course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Django Comment – FAQs

Quick answers about learning Django Comment in Django.

This free note from CodingNow 2.0 explains Django Comment in Django — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Django topic on CodingNow 2.0, including Django Comment, is 100% free with no signup required.
With focused practice, most students grasp Django Comment in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now