0

First off, I am new to django. I am trying to use GeoLite(GeoIP2) datasets in my POSTGIS database in Django 1.10. When I attempt to configure the myapp/settings.py file, i get error messages.There seem to be database backends in different paths in the django directory;Can you please clarify why?

  1. django\contrib\gis\db\backends\postgis
  2. django\db\backends

After activating my python3 virtual environment, when i try to set the default database in my settings.py file as postgresql('django.db.backends.postgresql'), i get an error:

AttributeError:”Database Operations’ object has no attribute ‘geo_db_type’.

When i try to use POSTGIS as my database engine (i set the GDAL_LIBRARY_PATH in my virtual environment), i get an error:

django.contrib.gis.db.backends.postgis' is not an available database backend. Try using 'django.db.backends.XXX', where XXX is one of 'mysql', 'oracle', 'postgresql',and 'sqlite'.
Error was: Cannot import name ‘GDALRaster’.

Can you suggest possible solutions to the above error messages? Thank you.

1 Answer 1

1

Installed GDAL from Christopher Gohlke’s site (32 bit GDAL-2.0.3-cp35-cp35m-win32.whl)into the virtual environment. Download OSGEO4W (32 bit) and install the Express Web option. Create Environment Variables. Set the environment variables as below:

set PYTHON_ROOT=C:\Python35-32 set GDAL_DATA=C:\Program Files\PostgreSQL\9.6\gdal-data set PROJ_LIB=C:\Program Files\PostgreSQL\9.6\share\contrib\postgis\proj set PATH=%PATH%;%PYTHON_ROOT%;%OSGEO4W_ROOT%\bin reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /f /d "%PATH%" reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v GDAL_DATA /t REG_EXPAND_SZ /f /d "%GDAL_DATA%" reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"

I also set LD_LIBRARY_PATH as C:\Python35-32\myvenv_python3\Lib\site-packages\osgeo. Then, the database is Improperly configured and cannot import 'GDALRaster' went away.From your django project directory, it would be possible to migrate now using: python manage.py migrate

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.