我有 3 个模型 userprofile 和 group :
class UserProfile(models.Model):
slug = models.SlugField(max_length=200)
user = models.ForeignKey(User, unique =True)
professionalNetwork = models.ForeignKey('SubForum',null=True, blank=True)
class Group(models.Model):
slug = models.SlugField(max_length=200)
name = models.CharField(max_length=200)
professionalNetwork = models.ForeignKey('SubForum')
class SubForum(models.Model):
name = models.CharField(max_length=200)
我如何获得与特定用户具有相同专业网络的所有组,然后是其余组?
我正在研究诸如 Group.objects.all().order_by('-professionalNetwork = profile.professionalNetwork') 之类的东西,但这当然行不通^^
谢谢