0

There is a really old thread on stackoverflow here Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb

but the difference that I have with their issue is that my containers have the POSTGIS and POSTGRES installed in. Specifically I used QGIS and the image is like so

db:

image: kartoza/postgis:13.0

volumes:

- postgis-data:/var/lib/postgresql

So locally I have two docker images - one is web and the other is the kartoza/postgis

I also have this as well in the settings.py file

import dj_database_url

db_from_env = dj_database_url.config(conn_max_age=500)

DATABASES['default'].update(db_from_env)

which should support the GIS data. I see all my packages gis, geolocation packages installed with no issues. But I am getting the above error when I run heroku run python manage.py migrate

The website runs with very limited functionality as the geo variables are needed to get you past the landing page.

The steps I have taken to deploy is

heroku create appname

heroku stack:set container -a appname

heroku addons:create heroku-postgresql:hobby-dev -a appname

heroku git:remote -a appname

git push heroku main

EDIT The db url on heroku is postgres://foobar:[email protected] I have also ran the below command and it shows that the db now takes GIS, but I still get the error

$ heroku pg:psql
create extension postgis;

2 Answers 2

0

try replacing db with localhost

heroku config:add DATABASE_URL=postgis://foo:bar@localhost:5432/gis
Sign up to request clarification or add additional context in comments.

1 Comment

This isn't working. My docker container has both POSGIS and POSTGRES installed in it. Getting the same error. The DATABASE_URL is showing as //postgres1234567890wsfoobar when I insert the command heroku addons:create heroku-postgresql:hobby-dev -a appname. I think I have to figure out how to build a heroku database that has GIS capabilities.
0

Ok so after 14 or so hours of reading. The issue here is that

  1. Heroku database does NOT have qgis capabilities enabled as a default - you have to use heroku pg:psql then run CREATE EXTENSION postgis;
  2. Having QGIS installed within the docker container results it not being able to perform functions such as hero pg:push localdatabase -postgresqlremoteherokudb and heroku config:add DATABASE_URL=postgis://foo:bar@localhost:5432/gis So if anyone is following the python nearbyshops tutorial, you might end up here as well. I got fixated here thinking it's a db issue, but it was more so to do with heroku configuration settings.
  3. If you are coming here from docker, which might mean you need to install django_heroku package to modify your settings. There are recent 2019 and 2018 guides on how to deploy Geospatial apps to heroku, but again, you don't need those. (at least for me I didn't)
  4. GIS now is available as an extension, you no longer need to add buildpacks.

There are still some configuration issues if you are using gunicorn for staticfiles, so the website at first won't launch properly. Highly suggest that you track your heroku log errors (manual settings.py coding or heroku addons).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.