Django GetStream 和 Django 注释

Django GetStream and Django comment

如何使用 django_comments 从 Django GetStream 中保存 activity 以及如何获取此数据?谢谢!

我已经用 render_comment_form 实现了 Django 评论,类似 https://django.readthedocs.org/en/1.4.X/ref/contrib/comments/ 我想知道如何在 GetStream 中保存 activity 以及如何进行咨询保存后谢谢 谢谢你,但我有类似的东西:

from django.db import models
from fluent_comments.compat import CommentManager, Comment #, signals
from fluent_comments.models import FluentComment
from stream_django.activity import Activity
from stream_django import feed_manager
from django.db.models import signals
from publications.models import Ad

class ActivityComments(FluentComment, Activity):
    pass

    def __unicode__(self):
        #return "%s COMENTA-->> %s" % (self.user.first_name, self.object_content.item)
        return "%s COMENTA-->> %s" % (self.user.first_name, self.object_pk)

    @property
    def activity_object_attr(self):
        return self

    @property
    def activity_actor_attr(self):
        return self.user

    @property
    def activity_time(self):
        return self.created

    @property
    def extra_activity_data(self):
        return {'a': self.item}

    @property
    def activity_notify(self):
        if self.object_content.item.seller.user != self.user:
            target_feed = feed_manager.get_notification_feed(
                self.object_content.item.seller.user.id)
            return [target_feed]

    @classmethod
    def apply_activity_notify(cls, sender, instance, using, **kwargs):

        ad=Ad.objects.get(id=instance.object_pk)
        comment = FluentComment.objects.get(id=instance.id)
        comment.object_content = ad
        comment.activity_notify


"""
signals
"""

signals.post_save.connect(ActivityComments.apply_activity_notify, sender=Comment)

我想有了这个我可以注册活动,但是当我去 getstram 管理员时我什么也没有。另外,另一个问题,当注册完成后,我可以得到 activity 吗?:

enricher = Enrich()
feed = feed_manager.get_feed('flat', user.id)
activities = feed.get(limit=3)['results']
I hope your answer, Thanks.

Django Comment 允许您自定义用于存储评论的模型。

首先您需要创建一个应用程序来保存 Django Comment 的自定义并将其添加到您的 settings.py

INSTALLED_APPS = [
    ...
    'my_comment_app',
]

COMMENTS_APP = 'my_comment_app'

然后在 my_comment_app/models.py 中,您需要将 Comment 模型注册为 Stream activity.

from django.db import models
from django.contrib.comments.models import Comment
from stream_django.activity import Activity

class ActivityComment(Comment, Activity):
    pass

然后您需要将您的自定义应用程序注册到 Django Comment,为此添加到 my_comment_app/__init__.py 此代码

from my_comment_app.models import ActivityComment


def get_model():
    return ActivityComment