私は次の2つのモデルを持っています:
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()
基本的に以下を1つの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')