Closed leonL closed 6 years ago
Hmm, this support is a bit janky. Let me try to reproduce. Can you share your settings file, @leonL?
This is working well for me!
Did you $ heroku config:set BUILD_WITH_GEO_LIBRARIES=1
?
Hi @kennethreitz, thanks for your help.
I did set BUILD_WITH_GEO_LIBRARIES=1
, yes but I have a feeling it's not working: The echo statements displayed when I push my repo to heroku don't show any evidence of the related dependencies being installed and when I try gdal.HAS_GDAL from the python shell I get False.
My settings file looks like this...
import os
import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = False
ALLOWED_HOSTS = [
'sleepy-scrubland-24958.herokuapp.com',
'0.0.0.0'
]
INSTALLED_APPS = [
'api.apps.ApiConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'rest_framework'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'snm_server.urls'
CORS_ORIGIN_ALLOW_ALL = True
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'snm_server.wsgi.application'
DATABASES = {'default': {}}
DATABASES['default'] = dj_database_url.config()
DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
Are you on heroku-16
stack?
$ heroku stack
I am, yes.
@kennethreitz, FYI I just performed the following test, which perhaps isolates the problem...
@kennethreitz, could you please post the process you are taking to test that the dependencies are installing correctly on the Heroku build? I'll try reproducing it, and perhaps it will give me some insight into what I need to change on my builds to make it work.
Thanks, Leon
@kennethreitz, I changed my stack to cedar-14 and it solved all my problems. I'm gonna stay on that stack for the time being. If there's anything you'd like me to try out on the heroku-16 stack I'm happy to help.
Best, L.
Hey y'all! I think I solved this with https://github.com/heroku/heroku-buildpack-python/pull/449 - if you want to specify my branch with these changes, you can use https://github.com/TrailblazingTech/heroku-buildpack-python#fix-gdal-jasper
.
You will need to add two lines to your settings.py as I detailed in the PR as well, so that Django can load gdal and geos.
@zachmccormick really looking forward to trying out your changes this week!
Heroku-16 and GEOS do not play well together. I'm going to update the documentation today to reflect this.
The release of Django 2.0 may solve this.
I am experiencing the same problem with Django 2.0.6, Heroku-16 and BUILD_WITH_GEO_LIBRARIES=1
When building, one of the log statements returned from the push was 'Bootstrapping gdal, geos, proj'
When testing GDAL:
from django.contrib.gis.gdal import HAS_GDAL
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: cannot import name 'HAS_GDAL'
Hey @danielskun ! Check out this commit that is included in 2.0a1 onward: https://github.com/django/django/commit/2dc3280254ae06ca1fe664abf55749fe12a699d4#diff-6d623ebf16b95ff941111fa162d02236
It removes HAS_GDAL and actually seems to do a decent bit of reorganizing the code around absolutely requiring GDAL (as of Django 1.11, if you use contrib.gis, it's required). I would fork this buildpack and try to figure it out using that commit as a starting point. If you can't get it to work, ping me and I'll give it a shot this weekend.
Hi. I'm having trouble configuring a heroku-16 instance to support GeoDjango. I've followed the documentation on the Heroku site closely, but always encounter the error:
Could this be related to any of the recent issues/changes related to this repo having to do with GIS dependencies like GDAL and GEOS. Thanks for any ideas.