我正在使用django-activity-stream
应用并尝试write custom 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)
views.py
from actstream.models import Action
current_user = get_object_or_404(User, username=username)
current_user.actor_actions.mystream('commented')
settings.py
ACTSTREAM_MANAGER = 'accounts.managers.MyActionManager'
错误讯息> 'str' object has no attribute 'actor_actions'
和full traceback
非常感谢
答案 0 :(得分:0)
django-activity-stream
。
这是您在此issue上与某人分享的错误。你应该参与那个页面,所以justquick可以解决看起来像个bug的问题。
答案 1 :(得分: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)