python - Google App Engine 上的 Django 和 GeoSpatial 查询 - 如何克服 'one inequality per query' 问题?

标签 python django google-app-engine google-cloud-datastore django-nonrel

我刚刚开始使用 GAE,偶然发现了一个问题,这让我质疑在 GAE 上使用 Django 的可行性。

我想做的只是使用 Django 的 ORM 进行简单查询:

addresses = Address.objects.filter(lat__gte=form.cleaned_data['north_east_lat'])
addresses = addresses.filter(lat__lte=form.cleaned_data['south_west_lat'])
addresses = addresses.filter(lon__gte=form.cleaned_data['north_east_lon'])
addresses = addresses.filter(lon__lte=form.cleaned_data['south_west_lon'])

但显然 Bigtable 并不那么容易:

BadFilterError:过滤器无效:每个查询只能有一个属性具有不等式过滤器(<=、>=、<、>)..

如何解决这个问题? (最好使用Django的ORM)

最佳答案

不幸的是,我不知道使用 Django 的 ORM 来解决这个问题的简单方法。但是,您可以在 GAE 上执行地理空间查询(包括像您在示例中所做的那样的边界框查询)。详情请查看Geospatial Queries with Google App Engine using GeoModel文章。

关于python - Google App Engine 上的 Django 和 GeoSpatial 查询 - 如何克服 'one inequality per query' 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5292402/

相关文章:

python - 在 `super()` 内使用 `__init_subclass__` 找不到父类的类方法

python - 将 ndb.Tasklets 与 memcache 读取相结合

python - Django:从 urls.py 获取网址名称

python - 在 Sphinx 自动摘要中使用第一段而不是第一行

python - 在python pandas中添加组列的百分比

python - 登录、注册和注销测试失败 AssertionError : 200 ! = 302 django

python - DRF形式渲染对象属性(名称)而不是对象

django - django 中 SITE_ID 设置的用途是什么?

java - Google Appengine Java 使用哪种 JVM 语言 + Web 框架?

python - 按非ascii字符查询