Customising comment framework and keeping moderation working

16 views
Skip to first unread message

Phil Gyford

unread,
Oct 5, 2010, 6:27:00 AM10/5/10
to django...@googlegroups.com
Hi,

I can't get my extended version of django.contrib.comments to take
notice of moderation.

If I use the standard comments framework, then my subclass of
CommentModerator does the job - I've just used it to define
enable_field, and this allows or prohibits comments as expected.

But if I switch to using my custom version of the comments framework
(which adds an extra field) it seems like the moderator is ignored -
all comments are allowed through, no matter whether the enable_field
on the commented-on object is true or false.

I can't see what I'm missing. Here's the code for my moderator, in
case it helps: http://dpaste.com/253308/ It works fine like that, with
the standard framework, but if I switch the import lines over, add my
custom comments app to INSTALLED_APPS and COMMENTS_APP settings, the
enable_field has no effect.

What's the magical missing step....? Thanks.

Phil

--
http://www.gyford.com/

Phil Gyford

unread,
Oct 5, 2010, 9:46:17 AM10/5/10
to django...@googlegroups.com
I've investigated further and... it's very strange.

I've got a version of my custom comments framework, with
enable_comments moderation, working fine. Here are the contents of my
working customcomments/forms.py and customcomments/models.py:
http://dpaste.com/253382/

However, if I add "from weblog.models import Blog" to either of those
files, my custom moderation has no effect.

This is a problem, because what I really want to do is not add a
'title' field to each custom comment, but add a ForeignKey field that
links to the Blog object (comments are posted on Entries, each of
which is associated with a Blog). So I will need to import the Blog
class.

In case it helps, here's the contents of weblog/models.py that
contains the Blog class: http://dpaste.com/253384/

This modification really isn't worth the two days I've now spent
puzzling over it, but it's got personal, and I just want to understand
the solution now! Any help very much appreciated.

--
http://www.gyford.com/

Phil Gyford

unread,
Oct 5, 2010, 10:36:34 AM10/5/10
to django...@googlegroups.com
I've made as minimal a complete demonstration of this as possible, to
try and work out where I'm going wrong:
http://github.com/philgyford/django-commentstest/

It works fine: comments can successfully be disabled on a per-Entry
basis. But, if you add "from weblog.models import Entry" to either
customcomments/forms.py or customcomments/models.py then comments are
*always* allowed through. Any idea why? Thanks.

--
http://www.gyford.com/

Klaas van Schelven

unread,
Oct 6, 2010, 4:06:47 AM10/6/10
to Django users
Phil,

A quick reply so I may be wrong on the details.
I think you're running into a limitation on the standard way of doing
things in Django.

I've talked about this before here:
http://groups.google.com/group/django-users/browse_thread/thread/22875fd287d0aa81/d6cf04a857424678?show_docid=d6cf04a857424678

and here:
http://groups.google.com/group/django-developers/browse_thread/thread/363fc7f3ca107f94/25a85be6cce875ed?hide_quotes=no

no time for a full reply here but if it's gotten personal this might
help you a bit,

Klaas
> >> case it helps:http://dpaste.com/253308/It works fine like that, with

Phil Gyford

unread,
Oct 6, 2010, 5:14:56 AM10/6/10
to django...@googlegroups.com
Thanks Klaas. That second one does seem related to my problem although
after a couple of days struggling with this issue I'm now at the
limits of my knowledge and don't know if it actually helps me :)

I found what seems like a related ticket that's been opened and closed
a couple of times and tentatively re-opened it with an explanation:
http://code.djangoproject.com/ticket/12812

I'm going to have to move on though and try and work around the
problem for now as this frustration is doing me no good at all :(

Phil

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

--
http://www.gyford.com/

Reply all
Reply to author
Forward
0 new messages