以下lte和gte筛选器查询返回0个对象:
curl http://localhost/river/river/?runoff__lte=100.0&runoff__gte=150.0
curl http://localhost/river/river/?runoff__lte=100&runoff__gte=150
http://localhost/river/river/?dt_timestamp__lte=2015-01-01T03:00&dt_timestamp__gte=2015-01-07T18:00&format=json
这里是型号.py
class River(models.Model):
dt_timestamp = models.DateTimeField()
stage = models.DecimalField(max_digits=10, decimal_places=3, blank=True, null=True)
runoff = models.DecimalField(max_digits=10, decimal_places=3)
api.py公司
class RiverResults(ModelResource):
class Meta:
queryset = River.objects.all()
resource_name = 'river'
authorization = Authorization()
filtering = {
'user': ALL_WITH_RELATIONS,
'dt_timestamp': ALL
'stage': ALL,
'runoff': ALL,
}
在设置.py使用\u TZ=False
我正在运行Postgresql 9.3、Django 1.6和Tastypie 0.12.2。 不知道我做错了什么。你知道吗
谨致问候, 艾伦
我想您需要选择
runoff
介于100和150之间的河流,或者dt_timestamp
介于2015-01-01T03:00和2015-01-07T18:00之间的河流。在这种情况下,请尝试:如果需要选择径流小于100或大于150的河流,则需要覆盖
build_filters
函数:使用方法:
相关问题 更多 >
编程相关推荐