Django notification comment get owner

I am looking at accessing the user who owns the content_type of a posted comment

Currently I can access the user who posts, the comment, however I would like to notify the person who owns the item...

I tried doing user = comment.content_type.user but I get an error.

In my main __init__.py file

As soon as I change that to user = request.user it works fine, but then the notification gets sent to the person who made the comment.

from django.contrib.comments.signals import comment_was_posted

if "notification" in settings.INSTALLED_APPS:
    from notification import models as notification

    def comment_notification(sender, comment, request, **kwargs):
        subject = comment.content_object
        for role in ['user']:
            if hasattr(subject, role) and isinstance(getattr(subject, role), User):
                user = getattr(subject, role)
                message = comment
                notification.send([user], "new_comment", {'message': message,})

    comment_was_posted.connect(comment_notification)
1
задан ApPeL 28 September 2010 в 08:14
поделиться