0

我正在使用django-activity-stream应用程序并尝试编写自定义流

帐户/managers.py

from datetime import datetime
from django.contrib.contenttypes.models import ContentType
from actstream.managers import ActionManager, stream
class MyActionManager(ActionManager):
    @stream
    def mystream(self, obj, verb='posted', time=None):
        if time is None:
            time = datetime.now()
        return obj.actor_actions.filter(verb = verb, timestamp__lte = time)

视图.py

from actstream.models import Action
current_user = get_object_or_404(User, username=username)
current_user.actor_actions.mystream('commented')

设置.py

ACTSTREAM_MANAGER = 'accounts.managers.MyActionManager'

错误消息 >'str' object has no attribute 'actor_actions'完整的回溯

多谢

4

2 回答 2

0

我刚遇到这个问题,不知道什么时候开始发生。我前段时间更新到 Django 1.4,我刚开始看到这些问题。

我最终做的是还原查询

@stream
def my_stream(object, *args, **kwargs):
    ct = ContentType.objects.get_for_model(object.__class__)
    return self.model.objects.filter(actor_object_id=object.pk, 
        actor_content_type=ct, public=True, **kwargs)
于 2013-05-30T06:38:42.900 回答
0

django-activity-stream最近 Django 1.4 对我来说已经被破坏了。这是您在此问题上与某人分享的错误。您应该参与该页面,以便 justquick 可以修复看起来像错误的问题。

于 2012-05-14T13:31:23.213 回答