views:

32

answers:

2

I am using the django comments system and everything is working ok apart from the comments are being added into the table with is_public being set to false.

Does anyone know why this is and how I can fix it, i.e. have them set as true

edit, this is the code I have:

{% load comments %}

<ul>
{% get_comment_list for entry as comment_list %}
{% for c in comment_list %}
<li>{{c.comment|safe|linebreaksbr}} - {{c.user_name}}, <span>left {{ c.submit_date|timesince }} ago)</span></li>
{% empty %}
<li>
   No comments have been added
</li>
{% endfor %}
</ul>

{% get_comment_form for entry as form %}

<form action="{% comment_form_target %}" method="POST">
    {{ form.content_type }}
    {{ form.object_pk }}
    {{ form.timestamp }}
    {{ form.security_hash }}
    <p style="display:none">
      {{ form.honeypot }}
    </p>
    <input type="hidden" name="next" value="/public/blog/post/{{entry.slug}}/" />
            <div class="contentSectionTitleWhite">
                LEAVE COMMENT
            </div>
            <div class="postLeaveReplayContainer">
                <!-- NAME --><span class="commonControlLabel">Your name:</span>&nbsp;<span class="commonControlLabelItalic">(required)</span>
                <span id="postNameErrorMsg" class="commonControlErrorMsg"></span>
                <br/>
                <input class="commonInput" type="text" id="id_name" name="name" />
                <br/>
                <!-- EMAIL --><span class="commonControlLabel">Your email:</span>&nbsp; <span class="commonControlLabelItalic">(required, will not be published)</span>
                <span id="postEmailErrorMsg" class="commonControlErrorMsg"></span>
                <br/>
                <input class="commonInput" type="text" id="id_email" name="email" />
                <br/>
                <!-- MESSAGE --><span class="commonControlLabel">Message:</span>&nbsp;<span class="commonControlLabelItalic">(required)</span>
                <span id="postMessageErrorMsg" class="commonControlErrorMsg"></span>
                <textarea class="commonTextarea" rows="20" cols="20" id="id_comment" name="comment">
                </textarea>
                <br/>
                <!-- SEND BUTTON --><input type="submit" value="Submit" id="postSendButton" class="readViewMoreBtn">

        </form>
A: 

strange, because (at least in Django 1.2) the default is set to True:

is_public   = models.BooleanField(_('is public'), default=True,
                help_text=_('Uncheck this box to make the comment effectively ' \
                            'disappear from the site.'))

Are you shure you do not explicity set it to False in any view yourself?

Or did you use the Generic comment moderation? Possibly the auto moderation is used. It set the is_public field of new comments to False before saving them (To avoid Spam)

maersu
yeah thats what i thought and i've done it on other sites and its worked fine. is there any setting or overrides which set it to false? If for example an email is wrongly formatted.
John
So you didn't use the Generic comment moderation app?
maersu
no, not as far as i am aware. I am using Django 1.1 though
John
A: 

To get this to work I added the following code to my model

def moderate_comment(sender, instance, **kwargs):
    if not instance.id:
        instance.is_public = True

signals.pre_save.connect(moderate_comment, sender=Comment)
John