tags:

views:

79

answers:

2

I'm trying to add the comments framework to a weblog I'm creating in Django. Adding the comments system appears to be working fine until I attempt to enable comment moderation.

I add the following code to my models.py as per the instructions on the above link. My model is called Post which represents a post in the weblog.

class PostModerator(CommentModerator):
    email_notification = False
    enable_field = 'allow_comments'

moderator.register(Post, PostModerator)

If I attempt to preview the site I get error AlreadyModerated at / with the exception The model 'post' is already being moderated. I have no idea why I'm getting this error as I have only just enabled comments and am not sure why Post would already be moderated.

A: 

I imagine that CommentModerator (the superclass for PostModerator) is moderated by default?

godswearhats
+1  A: 

Just had a similar problem today, but I think I've solved it :) In my case the issue was that django was loading models.py twice and therefore trying to register the model for comment moderation twice as well. I fixed this by modifying the code from:

moderator.register(Post, PostModerator)

to:

if Post not in moderator._registry:
    moderator.register(Post, PostModerator)
Monika Sulik