comments#

HTMX-integrated threaded comment system for blog posts with reCAPTCHA spam protection.

Models#

Model

Description

Comment

Blog post comment with threaded reply support (self-referencing parent FK)

URL Routes#

Path

View

Description

/comments/blogpost/<pk>/section/

comment_section

GET: render comment form + list (HTMX fragment)

/comments/blogpost/<pk>/add/

add_comment

POST: create new comment, re-render section

Key Design Decisions#

  • HTMX fragments: Both endpoints return HTML partials, not full pages. The blog post detail page loads comments via hx-get for faster initial page load.

  • Threaded replies: parent FK (self-referencing, nullable) enables one level of nesting. The template groups replies under their parent.

  • Soft delete: The active boolean allows moderation without losing data.

  • reCAPTCHA: Comment submission is protected against spam via Google reCAPTCHA validation on the server side.