I'm just doing my first steps with Python a Django and I'd like to use it with GeoIP on my Mac. I've used Homebrew and pip for installing everything I need, but I haven't figured out how to set path for GeoIP. So I always get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/django/contrib/gis/geoip/base.py", line 91, in __init__
if not path: raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
django.contrib.gis.geoip.base.GeoIPException: GeoIP path must be provided via parameter or the GEOIP_PATH setting.
You need the GeoIP data which you can download from MaxMind , and you need to set up GEOIP_PATH in your settings.py module to point to wherever you download that GeoIP data.
Your directory structure might not be exactly the same as this, but for me I have
<project directory>
...
geoip
...
<app_directory>
settings.py
...
In my settings.py I have a ROOT_PATH set up to refer to the project directory, so
GEOIP_PATH = ROOT_PATH + '/geoip'
Download the binary / gzip version of the GeoIP data you need, unzip it and put it in that geoip directory.
与其他Django设置相同:通过项目的settings
模块。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.