我有以下模特:
class Name(models.Model):
name = models.SlugField(max_length=100)
primary = models.BooleanField()
project = models.ForeignKey(
Project, null=True, blank=True, on_delete=models.DO_NOTHING, related_name="names")
class Robject(models.Model):
project = models.ForeignKey(to=Project, null=True, blank=True)
names = models.ManyToManyField(
"Name",
related_name="robjects",
limit_choices_to= limit_name_choices,
blank=True
)
[...]
我正在寻找Name过滤器查找,它只给出了与任何robject无关的名称。
提前致谢!
答案 0 :(得分:0)
你可以做一个简单的过滤器:
Name.objects.filter(robjects=None)