Postgis is not an affordable database backend

I encountered this error when configuring geodjango in a django 1.9 working application.

My application lives inside an Amazon EC2 instance plus a postgres RDS instance.

Error:

django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.postgis' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3 

What I've done:

  • Install GEOS, PROJ.4 and PostGIS as described in the geodjango doc .
  • Install PostGIS in amazon RDS as described in the amazon doc .
  • Modify my settings.py project to include:

    • INSTALLED_APPS = (... 'django.contrib.admin', ... 'django.contrib.gis')
    • GEOS_LIBRARY_PATH = '/usr/local/lib/libgeos_c.so'
    • DATABASES = {... 'ENGINE': 'django.contrib.gis.db.backends.postgis' ...}
  • Modify my models.py application to import models from django.contrib.gis.db instead of django.db

Can you guess what I am missing?

+5
source share
2 answers

Run this command

sudo apt-get install binutils libproj-dev gdal-bin

This is described in this documentation.

+5
source

I found that my libgdal library is causing me problems and giving me this error.

I work in windows in a conda environment with Django 1.11 and GDAL 2.0. Changing the versions of GDAL and django does not seem to fix anything. However, setting the libgdal version to 1.11.2 seemed to clear the error for me.

0
source

Source: https://habr.com/ru/post/1243652/


All Articles