use Django GeoIP database for models
-
28-10-2019 - |
Question
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.
Solution
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/