Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6135831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:31:36+00:00 2026-05-23T17:31:36+00:00

I’ve just implemented django-comments. settings.py INSTALLED_APPS = ( … ‘django.contrib.comments’, ) product_detail.html {% get_comment_count

  • 0

I’ve just implemented django-comments.

settings.py

INSTALLED_APPS = (
    ...
    'django.contrib.comments',
)

product_detail.html

{% get_comment_count for product as comment_count %}
<p>This event has {{ comment_count }} comments.</p>

{% render_comment_list for product %}
{% render_comment_form for product %}

templates/comments/form.html

{% load comments i18n %}
{% if user.is_authenticated %}
    <form action="{% comment_form_target %}" method="post">
        {% csrf_token %}
        <input type="hidden" name="next" value="/product/{{ product.id }}/" />
        {% for field in form %}
            {% if field.is_hidden %}
                {{ field }}
            {% else %}
                {% if field.name != "name" and field.name != "email" and field.name != "url" %}
                    {% if field.errors %}{{ field.errors }}{% endif %}
                    <p {% if field.errors %} class="error"{% endif %} {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
                    {{ field }}
                    </p>
                {% endif %}
            {% endif %}
        {% endfor %}
        <input type="submit" name="post" class="submit-post" value="{% trans "Add Comment" %}" />
    </form>
{% else %}
    I'm sorry, but you must be <a href="javascript:alert('send to login page')">logged in</a> to submit comments.
{% endif %}

templates/comments/list.html

<div class="comment_start"></div>
{% for comment in comment_list reversed %}
    <div class="comment">
       {{ comment.comment }} 
       (from <a href="/user/{{ comment.user }}/">{{ comment.user }}</a> - {{ comment.submit_date|timesince }} ago)
    </div>
{% endfor %}

When form is rendered I see this html code:

1  <form action="/comments/post/" method="post"> 
2    <div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='39cad78f1b4adef30adb536717cesd71' /></div> 
3    <input type="hidden" name="next" value="/product/1/" /> 
4    <input type="hidden" name="content_type" value="myapp.product" id="id_content_type" /> 
5    <input type="hidden" name="object_pk" value="2" id="id_object_pk" /> 
6    <input type="hidden" name="timestamp" value="1310776114" id="id_timestamp" /> 
7    <input type="hidden" name="security_hash" value="34efe5f91239db95f429d07ec21a2926bf22a905b65" id="id_security_hash" /> 
8    <p><textarea id="id_comment" rows="10" cols="40" name="comment"></textarea></p> 
9    <p style="display:none;">
10        <input type="text" name="honeypot" id="id_honeypot" /> 
11   </p>    
12   <input type="submit" name="post" class="submit-post" value="Add Comment" /> 
13  </form> 

Questions:

  • See at the line 4. It’s ok there’s that value?
  • Is this a good way (with overriding form.html) for remove first name, last name and url fields from the form?
  • Is it okay this hardcode? value="/product/{{ product.id }}/
  • I would insert the comment with ajax/jquery and not with the page full-refresh, is it possible?

Thanks for all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:31:38+00:00Added an answer on May 23, 2026 at 5:31 pm

    Line 4 seems ok? I see no problem at least 😉 But of course always test your code 🙂

    The removal is a bit hackish, but that is also because the templatinglanguage is a bit limited. If you have a recent version you can probably use the in operator though: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#in-operator

    The hardcoding is not ok, use the url templatetag:
    https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#url

    You can do it with Ajax. I did that for the comment app using Dajax (a django app; http://www.dajaxproject.com ), and just calling the view from the dajax function, but you can call it from another function as well. My solution was letting Dajax render a html snippet, and just sending that back, and also use that snippet from the main template. That way the layout code was in one place (though not very network-usage-efficient).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.