[Django]-How to access a geometry (point) field in PostGIS database from Django?

3👍

The database configuration in settings.py was incorrect:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'geodjango',
        'USER': 'geo',
        'PASSWORD': 'secret',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Correct:

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis', # Here
        'NAME': 'geodjango',
        'USER': 'geo',
        'PASSWORD': 'secret',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

I have overseen this in the documentation somehow. Thanks to apollo13 from the #django irc channel for the advice into the right direction.

👤JJD

Leave a comment