简体   繁体   English

Django-Simple-Friends所有未作为朋友连接的用户

[英]Django-Simple-Friends all users not connected as friends

I'm tyring to create a list of users who could be invited with Django-Simple-Friends 我想创建一个可以与Django-Simple-Friends邀请的用户列表

I would like the list to include all active users minus the logged in user and all the logged in user's friends. 我希望该列表包括所有活动用户减去登录用户和所有登录用户的朋友。

I have a query that works to pull all the active users minus the logged in users but am not sure how to exclude the "friends" 我有一个查询,可以将所有活动用户减去已登录的用户,但不确定如何排除“朋友”

Here's the query I'm using for all active users minus logged in user: 这是我正在为所有活动用户减去登录用户使用的查询:

invite_user_list = User.objects.filter(~Q(id=request.user.id), is_active=True)

Any thoughts how I can remove the connected friends from the list? 有什么想法可以从列表中删除连接的朋友吗?

I appreciate the time and expertise. 我感谢您的时间和专业知识。

使用排除

invite_user_list = User.objects.filter(is_active=True).exclude(id=request.user.id).exclude(friendship__friends__user=request.user)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM