Django GetStream和Django注释

保罗·亚历山大

如何使用django_comments从Django GetStream保存活动,如何获取此数据?谢谢!

我已经用render_comment_form实现了Django注释,类似https://django.readthedocs.org/en/1.4.X/ref/contrib/comments/,我想知道如何在GetStream中保存活动以及如何保存后我请教一下谢谢谢谢你,但是我有这样的事情:

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管理员时,什么也没做。另外,另一个问题是,当寄存器被修改后,我可以用它进行活动吗:

enricher = Enrich()
feed = feed_manager.get_feed('flat', user.id)
activities = feed.get(limit=3)['results']
I hope your answer, Thanks.
汤玛索·巴布格利(Tommaso Barbugli)

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

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

INSTALLED_APPS = [
    ...
    'my_comment_app',
]

COMMENTS_APP = 'my_comment_app'

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章