Django:GeoDjango 适合我的网站吗?
我正在 Django 中构建一个房地产网站,并有一个 Home 模型,它存储包括地址在内的各种信息。数据库后端使用MySQL。
想要创建类似 Yelp 的搜索。
用户可以输入邮政编码或城市名称的搜索,然后获取该区域的主页结果。
用户还可以选择该点的半径(5英里、10英里...)并获得更多/更少的结果。
搜索结果将显示在谷歌地图上,用户可以放大/缩小以在地图中获取新的搜索结果。
Geo Django 适合这里吗?估计没有太多人使用 GeoDjango,因为我找不到很多文档来解决上述问题。
查看其官方文档大约几个小时后,我无法真正找到解决我的问题的相关示例,并且不确定它与使用 MySQL 的现有网站集成得如何。对于我简单的位置使用来说可能太复杂了?
我真的很好奇 Geo Django 是否合适,如果是的话……那么我会更积极、更深入地研究它。如果没有,我会尝试自己构建它。
任何有关 GeoDjango 或如何构建系统的指导或提示都会非常有帮助,我们将不胜感激。
I'm building a real estate site in Django and have a Home model, which stores various information including the address. Database backend is using MySQL.
Want to create a Yelp like search.
A search where users can enter in zip code or city name, then get Home results in that area.
Users can also choose the radius(5 mi, 10 mi...) from the point and get more/less results.
Search results will be on google map and users can zoom in/out to get new search results within the map.
Is Geo Django a good fit here? Guessing not too many people use GeoDjango, because I can't find many docs to solve problems mentioned above.
After looking at its official doc for about couple hours, I can't really find relevant example for my problems and not sure how well it integrates with existing website using MySQL. Maybe too sophisticated for my simple location usage?
I'm really curious if Geo Django is a good fit, if so..then I'll look into it more aggressively and deeply. If not, I'll try to build it on my own.
Any guidance or tips on GeoDjango or on how to build the system would be very helpful and will be appreciated so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
GeoDjango 可以处理类似的事情。假设您的
Home
模型如下所示:您可以获取某个点 x 英里内的所有
Home
模型,如下所示:基本上,您需要提供给过滤器的是一个元组包含几何图形(在您的情况下为点)和距离(使用
D
对象。在您的情况下,您有很大范围的单位来表示距离mi
)。另外,这在 MySQL 中不起作用,因为没有后端函数来处理它。最好的选择是 PostgreSQL。
GeoDjango could handle something like that. Supposing your
Home
model looks like this:You could fetch all
Home
models within x miles of a point like this:Basically, what you need to give to the filter is a tuple containing a Geometry (
Point
in your case), and the distance(with theD
object. You have a large range of units to represent the distance, in your casemi
).Also, this won't work in MySQL because there is no backend function to handle it. Your best bet is PostgreSQL.
我在 Django 上建立了一个具有类似功能的网站(MySQL 数据库包含地址和纬度/经度坐标)。我与更熟悉 Django 和 GeoDjango 的人进行了交谈,他们建议这对我的项目来说可能有点大材小用。
因此,如果迁移数据库是一个巨大的痛苦并且没有必要,那么看起来您可能会很好地坚持使用当前的数据库并仅使用半正弦公式查询来查找距某个位置最近的点。
I built a site on Django with similar features (MySQL database full of addresses and lat/long coordinates). I talked with cohorts that are more familiar with Django and GeoDjango and they recommended that it might be a bit overkill for my project.
So if migrating the database is a huge pain and not necessary, it seems you may be well off just sticking to your current database and just using a Haversine formula query to find closest points to a location.
如果您已经在使用 Django,那么 GeoDjango 会非常有意义。但是,您还应该考虑将 Lucene 用于您的用例。它可以处理地理查询,如果您需要进行多方面查询和模糊搜索(我想在有很多家庭的网站上使用它),它可能比 mysql 查询表现得更好。
GeoDjango makes a lot of sense if you're already using Django. However, you should also consider using Lucene for your use case. It can handle geographical queries, and probably performs better than mysql queries if you need to do multi-faceted queries and fuzzy search (something I would want to use on a site with a lot of homes).
GeoDjango 可以工作,但对于新手用户来说安装起来非常困难。 GeoDjango 对 MySQL 也有一些限制。据我所知,它显示了 postgresql 上最好的。
您在安装geodjango时到底遇到了什么问题?
在我开始了解 geodjango 安装过程之前,我已经浪费了大约 10-20 个小时:)
GeoDjango works but it is very hard to install for novice user. Also GeoDjango has some limitations on MySQL. As I know it shows the best on the postgresql.
What exactly problem do you experience in geodjango installation?
I've wasted about 10-20 hours before I began understand the geodjango installation process :)