Yet another commenting application for django
Python JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Yet Another Commenting App

Django commenting app that works something like hackernews.

Supports message threading, ajax and email notifications. It is the commenting system used on my blog at (demos are there). I wrote it since I just wanted really simple commenting support and from what I could tell there was not an app out there that did everything I wanted. Ie one would support ajax but not threading etc. I also had a difficuly time finding demos of the existing apps but I honestly didn't look very hard since I was looking for excuse to create an app anyways.

The reason is doesn't use django.contrib.comments is probably not a good one. I just didn't need all the stuff in there like moderation, anonymous posting etc. The interesting work was in the template rendering so if you just want to take that go for it.


  1. Get the source:

    pip install -e git+
  2. Add yacapp to INSTALLED_APPS your project's

  3. Add url include to your project's

    (r'^comments/', include('yacapp.urls')),
  4. Ensure django-yacapp static media is accessible, see managing static files.

  5. Run syncdb:

    python syncdb


  1. Update your models to support the generic relation:

    comments = generic.GenericRelation(yacapp_models.Comment,
    comment_count = models.IntegerField(default=0)
  2. Create your template for posting and displaying the comments. Requires jQuery <> and jQuery UI <> for the dialog popups:

    {% yacapp_tags %}
    {% with comment_count=post.comment_count %}
    <h2 class="comment-count">{{ comment_count }} Comment{{ comment_count|pluralize }}</h2>
    {% endwith %}
    <div class="comments">
      {% comments for post with "include/comment.html" %}
    <div class="comment-edit" title="Edit comment">
      <form action="#">
        <input type="hidden" id="comment_id"></input>
        <div class="fieldWrapper lastFieldWrapper">
          <label for="id_edit">Edit:</label>
          <textarea id="id_edit"></textarea>
        <button class="edit-save" type="submit">Save</button>
    <div class="comment-reply" title="Reply to comment">
      <p class="comment-text"></p>
      <form action="#">
        <input type="hidden" id="parent_id"></input>
        <div class="fieldWrapper lastFieldWrapper">
          <label for="id_reply">Reply:</label>
          <textarea id="id_reply"></textarea>
        <button class="post-reply" type="submit">Save</button>
    <div class="comment-form">
      <form action="#">
          <label class="comment-label" for="id_text">
          Comment as <span class="display-name">{{ request.user.get_profile.display_name }}</span> (<a class="change- settings" href="#">change</a>):</label>
          <textarea id="id_text"></textarea>
        <button class="post-button" type="submit">Post</button>
  3. Create your template for displaying the comment:

    <div class="comment level-{{ comment.level }}" id="comment-{{ }}">
      <p id="p-{{ }}">{{ comment.text|safe }}</p>
        <li>by {{ comment.user.get_profile.display_name }}</li>
        <li>{{ comment.created|timesince }} ago</li>
      <ul class="right">
        {% if request.user == comment.user %}
          <a id="edit-{{ }}" onclick="comment_edit(this, event)" href="#">Edit</a>
          <a id="delete-{{ }}" onclick="comment_delete(this, event)" href="#">Delete</a>
        {% else %}
          <a id="reply-{{ }}" onclick="comment_reply(this, event)" href="#">Reply</a>
        {% endif %}
      {% if replies %}
        <div class="replies">
          {{ replies|safe }}
      {% endif %}

Notice the {{ replies }} subsitution. That is how the recursion is handled for the multi-level commment replies.

Note: The js events are inline because I was not sure how to associate the events when the comment was inserted into the DOM. If you know how to do that with jquery please let me know.

  1. Include the js where its needed

#. Debug. This is my first app so its going to be rough but there enough should be there to get you started. Good Luck!!

Email notifications

Here is how you could support email notifications:

def comment_posted(sender, comment, request, **kwargs):
    from dakku import email_util

    for username, email in settings.ADMINS:
            settings=settings)'%s posted a comment' % (request.user))