[Django]-Geometry Doesn't exist in GEODJANGO

5👍

A couple of things to check for:

  • You’ve run CREATE EXTENSION postgis;
  • The GEOS_LIBRARY_PATH is set in your project’s settings.py file

This second point gave me some trouble, though it was the first that did the trick finally. I’m running this on Cygwin 64 bit, so there’s a bit of extra work to do to make it work. If you’re not running in the Cygwin environment, most likely the file you’re looking for is libgeos_c.so; I needed to point it to cyggeos_c-1.dll (still running on Windows, so the .dll extension is what I needed to find).

I was positive that I had run the CREATE EXTENSION command already, but I may not have run it in the Cygwin environment. Or I had tried, but had failed to remember that I have a nightmare of a configuration such that the postgres server is not running on localhost, so I was avoiding psql. Such is my own brand of thickness.

0👍

Here is the fixed ticket,

https://code.djangoproject.com/ticket/21547

Updated GeoDjango tutorial with PostGIS 2 output

👤dhana

0👍

In my case the issue was that the commands:

-- Enable PostGIS (includes raster)
CREATE EXTENSION postgis;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;

shoudl be run in context of certain database, so you need to connect to your_db first:

\connect your_db

and then run above!

0👍

try adding

objects = models.GeoManager()

after mpoly in your models.py

👤jcs

0👍

Assuming you are using postgis with your table/model in the public schema:

CREATE EXTENSION postgis;

Assuming you created another schema for your table/model, em settings.py add options:

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'OPTIONS': {
            'options': '-c search_path=YOUR_SCHEMA_NAME,public'
        },
        'NAME': 'DATABASE_NAME',
        'USER': 'DATABASE_USER',
        'PASSWORD': 'DATABASE_PASSWORD',
        'HOST': 'DATABASE_HOST',
        'PORT': 'DATABASE_PORT',
    }
}

Leave a comment