我有像这样的django模型
class AthleteSubscription(models.Model):
user = models.ForeignKey(User, related_name="user_subscription", default='')
subscription_start = models.DateField(default=datetime.date.today)
subscription_end = models.DateField(default=datetime.date.today() + timedelta(30))
其中subscription_start
是订阅的开始日期,subscription_end
是订阅的结束日期。订阅为30天。我想获取当前日期(今天的日期)介于subscription_start
和subscription_end
之间的记录。我怎么能用django ORM做到这一点。
答案 0 :(得分:3)
qv = AthleteSubscription.objects.filter(subscription_start__gte=some_date, subscription_end__lte=some_date)