有了这个模型
class Event(models.Model):
name = models.CharField('Name', max_length = 200)
class EventSchedule(models.Model):
event = models.ForeignKey(Event)
active = models.BooleanField(default = False)
sales_start = models.DateTimeField('Sales start')
sales_finish = models.DateTimeField('Sales end')
如何有效地获取至少有一个 EventSchedule 处于活动状态且在销售开始和结束期间的所有事件对象?
EventSchedule 对象的过滤器是
filter(active = True, sales_start__lte = now, sales_finish__gte = now)
但我需要 Event 对象而不是 EventSchedule 对象?