我有以下两个模型:
class JobPosition(models.Model):
job = models.ForeignKey(Job, related_name='positions')
position = models.ForeignKey('userprofile.Position')
date_added = models.DateTimeField()
end_date = models.DateTimeField()
class ExternalJob(models.Model):
name = models.CharField(max_length=256)
position = models.ForeignKey('userprofile.Position')
date_added = models.DateTimeField()
end_date = models.DateTimeField()
我将如何连接一个查询集,基本上将以下内容组合成一个 QS?
internal_jobs = JobPosition.objects.filter(end_date__gte=datetime.now())
external_jobs = ExternalJob.objects.filter(end_date__gte=datetime.now())
all_jobs = (internal_jobs + external_jobs).order_by('-date_added')