开发者

django comments why is the field is_public being set to false

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="commonCo开发者_开发问答ntrolErrorMsg"></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>


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)


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜