Ladislav M
Ladislav M

Reputation: 2187

How to properly set GEOIP_PATH for Django in OS X?

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.

Upvotes: 3

Views: 3413

Answers (2)

Liz Rice
Liz Rice

Reputation: 589

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.

Upvotes: 5

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798656

Same way as every other Django setting: via the settings module for the project.

Upvotes: 0

Related Questions