使用 Django GeoIP 数据库作为模型

发布于 2024-12-27 09:07:03 字数 245 浏览 2 评论 0原文

在我的应用程序中,我使用 django geoIP 来定位用户,它做得很好,但我还需要在我的用户模型中包含位置数据。在我的用户模型中,每个用户都有他们的国家(国籍)、城市(他们所在的位置)和坐标。我认为最好的方法是拥有与适当数据库关联的位置模型(或国家和城市模型)。 现在的问题是,我的模型是否可以使用GeoIP(maxmind GeoLiteCity-GeoIP binary db)使用的数据库?或者我是否需要一个自定义数据库来更好地满足我的目的。我也接受任何更好的方法。

In my App I use django geoIP to locate users and it does its job well, but I also need to include the location data in my users model. In my users model every user will have their country(nationality), city(where they are) and coordinates. I think the best way is to have a location model(or countries and cities model) associated with the appropriate database.
Now the question, is it possible to use the database used by GeoIP(maxmind GeoLiteCity-GeoIP binary db) for my model? or do I need a custom db which serves better my purpose. I also accept any better approach.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

束缚m 2025-01-03 09:07:03

我认为您无法为您的模型使用确切的 GEOip 数据库。他们确实提供 CSV 下载,可以轻松填充您的位置模型。

这是其他人基于 geoip 创建的位置模型 http://djangosnippets.org/snippets/327/

I don't think that you can use the exact GEOip database for your model. They do offer a CSV download which could easily populate your location model.

Here is a location model that someone else created based on geoip http://djangosnippets.org/snippets/327/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文