views:

144

answers:

1

I am implementing the stock Django comments to an existing site.

I'd like comments to appear in multiple apps and models and have all the comments behave the same - i.e. an email sent, plus other bits (listening to 'flag' signals and dealing with accordingly)

Where's the best place to put my custom moderator code?

I understand that I can pass in an iterator of Models to the register function - at first I placed it inside the __init__.py module of my main app as so:

from django.contrib.comments.moderation import moderator, CommentModerator

from app.models import Model1
from app2.models import Model2
#.... etc

class MyCommentModerator(CommentModerator):
    email_notification = True
    enable_field = 'enable_comments'
    #...

moderator.register(
    [Model1,Model2,Model3,Model4,...],
    MyCommentModerator
)

But this gave an error saying that Model1 was already registered.

I would probably re-factor this code into a comments_moderation.py module - but where should I include it?

Or is it best practice to register each model inside each apps models.py file?

Are there any samples out there that use comments?

I only found out how the Comment moderation queue works by trial and error - are there any docs for this that I've missed?

A: 

Comment Moderation Documentation

Definitely put the codein an own file and the file in a "helper" app (every project has one).

stefanw