Configuring a Postgresql POSTGIS database
<p>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?</p>

<ol>
<li>django\contrib\gis\db\backends\postgis </li>
<li>django\db\backends</li>
</ol>

<p>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:</p>

<pre><code>AttributeError:âDatabase Operationsâ object has no attribute âgeo_db_typeâ.
</code></pre>

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

<pre><code>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â.
</code></pre>

<p>Can you suggest possible solutions to the above error messages? Thank you.</p>

<p>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:</p>

<blockquote>
  <p>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%"</p>
</blockquote>

<p>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</p>

python django database postgresql geodjango