Template Comments
A snippet showing how to add comments in Django templates.
# models.py
from django.db import models
class Note(models.Model):
text = models.TextField()
def __str__(self):
return self.text[:30]
# admin.py
from django.contrib import admin
from .models import Note
@admin.register(Note)
class NoteAdmin(admin.ModelAdmin):
list_display = ("text",)
# templates/note_detail.html
{% comment %}
This section is a developer note and will not render in HTML output.
{% endcomment %}
<!-- Regular HTML comments ARE rendered in page source -->
Explanation:
-
Use
{% comment %}...{% endcomment %}to remove notes from final output. -
Regular
still appear in the page source.
- Category Templates
- Total Views 906
- Last Modified 24 January, 2026
- Tags #templates #comments #html #notes
Previous snippet
Static Files in Templates
Next snippet