Tastypieを使用して、日時フィールド範囲に基づいてオブジェクトをフィルタリングするにはどうすればよいですか。
私はポストモデルを持っています:
class Post(models.Model):
title = models.CharField(max_length=40)
postTime = models.DateTimeField(auto_now_add=True)
description = models.CharField(max_length=140)
投稿オブジェクトはTastypieを通じて取得されます。取得したいオブジェクトの範囲は、今日作成されたすべてのオブジェクトから 3 日前に作成されたすべてのオブジェクトです。そこで、次のようにクエリセットからオブジェクトをフィルタリングしてみました
RecentPosts(ModelResource):
class Meta:
queryset= Post.objects.filter(postTime__range=(date.today(), date.today() -timedelta(days=3)))
resource_name = 'recent-posts'
fields = ['id','postTime']
authentication = BasicAuthentication()
authorization =DjangoAuthorization()
serializer = Serializer(formats=['json'])
include_resource_uri = False
filtering = {
'postTime': ALL,
'description': ALL,
}
これを行った後でも、オブジェクトを取得できません。他にどうすればいいですか?