【问题标题】:How to query over two models to filter out a reference to a model?如何查询两个模型以过滤掉对模型的引用?
【发布时间】:2016-01-08 15:19:03
【问题描述】:

假设我有两个模型。

class Applicant(models.Model):
    firstName = models.CharField(max_length=50)
    applicationStatus = models.CharField(max_length=15, default="Pending")

class VolInterview(models.Model):
    applicant = models.OneToOneField('Applicant')
    reasonForRejection = models.CharField(max_length=1000, default="N/A")

现在我只想找到那些未被任何 VolInterivew 实例推荐的申请人。我该怎么做?

【问题讨论】:

    标签: django django-models django-database


    【解决方案1】:
    Applicant.objects.filter(volinterview__isnull=True)
    

    Django docisnull

    【讨论】:

      猜你喜欢
      • 2018-09-01
      • 1970-01-01
      • 2023-03-30
      • 2018-10-19
      • 2013-10-10
      • 1970-01-01
      • 1970-01-01
      • 2018-12-30
      • 1970-01-01
      相关资源
      最近更新 更多