Google App Engine 上的 Django 和 GeoSpatial 查询 - 如何克服“每个查询一个不等式”问题?
我刚刚开始使用 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: invalid filter: Only one property per query may have equal elements (<=, >=, <, >)..
我怎样才能解决这个问题? (最好使用Django的ORM)
I've just began to use the GAE and I have stumbled upon an issue which has let me questioning the feasibility of using Django on GAE.
All I'm trying to do is a simple query with Django's 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'])
But apparently it's not that easy with Bigtable:
BadFilterError: invalid filter: Only one property per query may have inequality filters (<=, >=, <, >)..
How can I get around this issue? (Using Django's ORM preferably)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,我不知道使用 Django 的 ORM 来解决这个问题的简单方法。但是,您可以在 GAE 上执行地理空间查询(包括像您在示例中所做的那样的边界框查询)。有关详情,请查看使用 GeoModel 通过 Google App Engine 进行地理空间查询文章。
Unfortunately, I don't know of an easy way to use Django's ORM to get around this issue. However, you can do geospatial queries on GAE (including bounding box queries like you're doing in your example). For details, please check out the Geospatial Queries with Google App Engine using GeoModel article.