{ "info": { "author": "Marco Chiappetta", "author_email": "lambdacomplete@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "=========\nEasyGeoIP\n=========\n\n**Note:** yes, I do know this app has PEP8 violations, is tightly coupled to DRF, yadda yadda yadda...It's useful for some people (me, first off), it's not for others. Feel free to open PRs but this is mostly a repository for myself (also a nice way to see how publishing a package to pypi works).\n\nEasyGeoIP is a Django app that enables IP address-based geo-location capabilities to your Django project based on a locally\nstored database released by `MaxMind `_.\n\nWhy EasyGeoIP?\n--------------\n\nBecause it's a nice wrapper over the included django.contrib.gis.geoip and doesn't require all that setup.\nYou just need to do `pip install django-easygeoip`.\n\nWhy not use a web API?\n----------------------\n\nBecause you have to register, get an API key, there might be a limitation on the number of queries, you might want to\nuse the service even when their server is not available, you might want to use different API keys on a staging and\nproduction server (which probably means registering two accounts). There are many reasons why a local database is preferrable.\n\nHow do I use it?\n----------------\n\nFirst off install the package (preferably in your virtual environment):\n::\n\n pip install django-easygeoip\n\nAdd it to the INSTALLED_APPS\n::\n\n INSTALLED_APPS = (\n ...\n 'easygeoip',\n ...\n )\n\nInclude its URLs (you can change the prefix `api` to whatever you want)\n::\n\n url(r'^api/', include('easygeoip.urls_api', namespace=\"easygeoip\")),\n\nOnce integrated into your project you will have two available endpoints:\n\n- `/api/location/<>/`\n- `/api/location/`\n\nThe first endpoint will use the IP address specified in the URL. The second endpoint will use the IP address within\nthe request object (yes, it understands the `X-Forwarded-For` header). The responses are in JSON.\n\nExamples\n--------\n\nExample request::\n\n GET /api/location/93.184.216.34/\n\nExample response::\n\n HTTP 200 OK\n {\n \"city\": \"Norwell\",\n \"continent_code\": \"NA\",\n \"region\": \"MA\",\n \"charset\": 0,\n \"area_code\": 781,\n \"longitude\": -70.82279968261719,\n \"country_code3\": \"USA\",\n \"latitude\": 42.15079879760742,\n \"postal_code\": \"02061\",\n \"dma_code\": 506,\n \"country_code\": \"US\",\n \"country_name\": \"United States\",\n \"ip_address\": \"93.184.216.34\"\n }\n\nExample response with invalid IP address::\n\n HTTP 400 Bad request\n {\n \"reason\": \"Invalid IP address\",\n \"ip_address\": \"0.0.0.0\"\n }\n\nExample response with invalid configuration::\n\n HTTP 500 Internal server error\n {\n \"reason\": \"Could not instantiate a GeoIP object. Did you set the GEOIP_PATH variable and downloaded the files?\",\n \"ip_address\": \"93.184.216.34\",\n \"exception_message\": \"GeoIP path must be a valid file or directory.\"\n }\n\nInstallation notes\n------------------\n\nOther than the usual drill (add to INSTALLED_APPS, include the URLs in your url_patterns etc.) there is one more step\nin order for this app to work. The package django.contrib.gis.geoip, used in this app, requires some binary files.\nSpecifically the GeoIP.dat and GeoLiteCity.dat databases are needed.\n\nThis app provides a utility function/Celery task that\nupdates the aforementioned files. Alternatively the GeoIP Update Program can be installed as a distribution package\non the system itself. I strongly suggest to simply run the task periodically (e.g. using Celery Beat or similar).\nThe files are updated \"the first Tuesday of every month\" (from the GeoIP docs).\n\nI want to download the files manually\n-------------------------------------\n\nSimply import easygeoip and run the task.\n::\n\n from easygeoip import tasks\n tasks.update_geoip_database()\n\n\nI want to run the task periodically\n-----------------------------------\n\nAn example of a monthly task for Celery beat:\n::\n\n CELERYBEAT_SCHEDULE={\n 'update_geoip_database': {\n 'task': 'easygeoip.tasks.update_geoip_database',\n 'schedule': timedelta(days=30),\n },\n [...]\n })\n\n\nIn the end settings.GEOIP_PATH should point to the directory where such files are regardless of the system used. This\ndirectory will also be used by this app to store the files. If not set the app will use the default path `/easygeoip/geoip_data/`.\n\nLogging\n-------\n\nYou can just add another logger to your LOGGING setting. Here is an example:\n::\n\n 'easygeoip': {\n 'handlers': ['myhandler'],\n 'propagate': True,\n 'level': 'DEBUG',\n },\n\nTesting\n-------\n\nTo run the test suite simply run `./manage.py test easygeoip` from your project directory.\n\nPypi\n----\n\nThe package is available here: https://pypi.python.org/pypi/django-easygeoip", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://lambdacomplete.me", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "django-easygeoip", "package_url": "https://pypi.org/project/django-easygeoip/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-easygeoip/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://lambdacomplete.me" }, "release_url": "https://pypi.org/project/django-easygeoip/0.0.3/", "requires_dist": null, "requires_python": null, "summary": "A simple Django app to include IP address-based geo-location capabilities to your project.", "version": "0.0.3" }, "last_serial": 2290538, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "6c16b541951012c1bc81bea514257053", "sha256": "6a8077d415e58929eb236cf49b761d9a75d76cf3da1ad6fcff71cb2524811f26" }, "downloads": -1, "filename": "django-easygeoip-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6c16b541951012c1bc81bea514257053", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6299, "upload_time": "2015-12-02T17:42:38", "url": "https://files.pythonhosted.org/packages/ba/b5/5fb79bc894a72884102c3ff82889f1d855b1c45dd2f48f544c9f55ffa151/django-easygeoip-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "583ef3bb078d6f3423d731916333ce0d", "sha256": "49730a5051f73e5ba2b348ec1b4c312a3c726e7da2f23427e1029e89fa631c29" }, "downloads": -1, "filename": "django-easygeoip-0.0.3.tar.gz", "has_sig": false, "md5_digest": "583ef3bb078d6f3423d731916333ce0d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6596, "upload_time": "2016-08-19T09:49:16", "url": "https://files.pythonhosted.org/packages/53/1a/ade50ab33339d263915e08714508e21a59f87cbb02410c33430c961533d3/django-easygeoip-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "583ef3bb078d6f3423d731916333ce0d", "sha256": "49730a5051f73e5ba2b348ec1b4c312a3c726e7da2f23427e1029e89fa631c29" }, "downloads": -1, "filename": "django-easygeoip-0.0.3.tar.gz", "has_sig": false, "md5_digest": "583ef3bb078d6f3423d731916333ce0d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6596, "upload_time": "2016-08-19T09:49:16", "url": "https://files.pythonhosted.org/packages/53/1a/ade50ab33339d263915e08714508e21a59f87cbb02410c33430c961533d3/django-easygeoip-0.0.3.tar.gz" } ] }