目前,我正在向数据库中的所有用户发送通知。如何获取所有朋友的列表,然后通知会发送给我的所有朋友?
if new and notification:
notification.send(User.objects.all().exclude(id=self.owner.id),
"listing_new",
{'listing':self, },
)
答案 0 :(得分:1)
您可以尝试:
from friends.models import Friendship
if new and notification:
notification.send(Friendship.objects.friends_for_user(self.owner.id), "listing_new", {'listing':self, }, )