5

I have launched an app on Heroku running Django 2.0.1 with a Postgres resource provisioned. My Procfile, after a few iterations, looks like this:

Procfile

release: python manage.py migrate --noinput
web: gunicorn app.wsgi --log-file -

When I deploy from GitHub (not from the command line... I haven't deployed from the command line before as it is critical to me that the GitHub deploy works) everything works fine. The migrations run like they should, and the logs confirm that there are no errors when migrating. In fact, there are no errors deploying to Heroku at all.

When I launch the site (forcing it into DEBUG mode to see the errors) I get this error on the front page:

ProgrammingError at /
relation "posts_post" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "posts_post" INNER JOIN "u...

A similar error exists when trying to load the admin site:

ProgrammingError at /admin/login/
relation "django_site" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
                                                             ^

I followed the advice in Django: relation "django_site" does not exist to migrate sites first, but that did nothing.

Also, this issue on GitHub is related, but was not helpful.

To clarify, the app is accessible. The Heroku deploy does not fail. The app is just erroring out.

Traceback (partial)

Environment:


Request Method: GET
Request URL: https://somesite.herokuapp.com/

Django Version: 2.0.1
Python Version: 3.6.4
Installed Applications:
['django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.humanize',
 'accounts.apps.AccountsConfig',
 'analytics.apps.AnalyticsConfig',
 'api_v1.apps.ApiV1Config',
 'api_v2.apps.ApiV2Config',
 'meta.apps.MetaConfig',
 'posts.apps.PostsConfig',
 'users.apps.UsersConfig',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'rest_framework']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware']



Traceback:

File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute
  85.                 return self.cursor.execute(sql, params)

The above exception (relation "posts_post" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "posts_post" INNER JOIN "u...
                                          ^

Why am I getting these errors? What can I do to get my Django deploy on Heroku working?

Additional info:

settings.py (obscured for security)

ABSOLUTE_URL_OVERRIDES={}
ACCOUNT_AUTHENTICATION_METHOD='username_email'
ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_UNIQUE_EMAIL=True
ADMINS=[]
ALLOWED_HOSTS=['somesite.herokuapp.com']
APPEND_SLASH=True
AUTHENTICATION_BACKENDS=('django.contrib.auth.backends.ModelBackend',
 'allauth.account.auth_backends.AuthenticationBackend')
AUTH_PASSWORD_VALIDATORS='********************'
AUTH_USER_MODEL='users.User'
BASE_DIR='/app'
BLEACH_ALLOWED_ATTRIBUTES={...}
BLEACH_ALLOWED_PROTOCOLS=[...]
BLEACH_ALLOWED_TAGS=[...]
CACHES={'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS='default'
CACHE_MIDDLEWARE_KEY_PREFIX='********************'
CACHE_MIDDLEWARE_SECONDS=600
CSRF_COOKIE_AGE=31449600
CSRF_COOKIE_DOMAIN=None
CSRF_COOKIE_HTTPONLY=False
CSRF_COOKIE_NAME='csrftoken'
CSRF_COOKIE_PATH='/'
CSRF_COOKIE_SECURE=False
CSRF_FAILURE_VIEW='django.views.csrf.csrf_failure'
CSRF_HEADER_NAME='HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS=[]
CSRF_USE_SESSIONS=False
DATABASES={'default': {'ATOMIC_REQUESTS': False,
             'AUTOCOMMIT': True,
             'CONN_MAX_AGE': 0,
             'ENGINE': 'django.db.backends.postgresql_psycopg2',
             'HOST': 'ec2-12-34-56-78.compute-1.amazonaws.com',
             'NAME': 'ddr3sshvtab',
             'OPTIONS': {},
             'PASSWORD': '********************',
             'PORT': 5432,
             'TEST': {'CHARSET': None,
                      'COLLATION': None,
                      'MIRROR': None,
                      'NAME': None},
             'TIME_ZONE': None,
             'USER': 'jabbathehutt'}}
DATABASE_ROUTERS=[]
DATA_UPLOAD_MAX_MEMORY_SIZE=2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS=1000
DATETIME_FORMAT='N j, Y, P'
DATETIME_INPUT_FORMATS=['%Y-%m-%d %H:%M:%S',
 '%Y-%m-%d %H:%M:%S.%f',
 '%Y-%m-%d %H:%M',
 '%Y-%m-%d',
 '%m/%d/%Y %H:%M:%S',
 '%m/%d/%Y %H:%M:%S.%f',
 '%m/%d/%Y %H:%M',
 '%m/%d/%Y',
 '%m/%d/%y %H:%M:%S',
 '%m/%d/%y %H:%M:%S.%f',
 '%m/%d/%y %H:%M',
 '%m/%d/%y']
DATE_FORMAT='N j, Y'
DATE_INPUT_FORMATS=['%Y-%m-%d',
 '%m/%d/%Y',
 '%m/%d/%y',
 '%b %d %Y',
 '%b %d, %Y',
 '%d %b %Y',
 '%d %b, %Y',
 '%B %d %Y',
 '%B %d, %Y',
 '%d %B %Y',
 '%d %B, %Y']
DEBUG=True
DEBUG_PROPAGATE_EXCEPTIONS=False
DECIMAL_SEPARATOR='.'
DEFAULT_CHARSET='utf-8'
DEFAULT_CONTENT_TYPE='text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER='django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE='django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL='webmaster@localhost'
DEFAULT_INDEX_TABLESPACE=''
DEFAULT_TABLESPACE=''
DISALLOWED_USER_AGENTS=[]
EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST='smtp.mailgun.org'
EMAIL_HOST_PASSWORD='********************'
EMAIL_HOST_USER='postmaster@mg.mailgun.com'
EMAIL_PORT=587
EMAIL_SSL_CERTFILE=None
EMAIL_SSL_KEYFILE='********************'
EMAIL_SUBJECT_PREFIX='[Django] '
EMAIL_TIMEOUT=None
EMAIL_USE_LOCALTIME=False
EMAIL_USE_SSL=False
EMAIL_USE_TLS=True
ERROR_404_VIDEO_EMBED_LINK='https://www.youtube.com/embed/GSRG0TqxLWc'
ERROR_FEEDBACK_FORM_LINK='https://short.url/here'
FILE_CHARSET='utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS=None
FILE_UPLOAD_HANDLERS=
['django.core.files.uploadhandler.MemoryFileUploadHandler',
 'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE=2621440
FILE_UPLOAD_PERMISSIONS=None
FILE_UPLOAD_TEMP_DIR=None
FIRST_DAY_OF_WEEK=0
FIXTURE_DIRS=[]
FORCE_SCRIPT_NAME=None
FORMAT_MODULE_PATH=None
FORM_RENDERER='django.forms.renderers.DjangoTemplates'
GOOGLE_ANALYTICS_TRACKING_ID='UA-1111111-8'
IGNORABLE_404_URLS=[]
INSTALLED_APPS=['django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.humanize',
 'accounts.apps.AccountsConfig',
 'analytics.apps.AnalyticsConfig',
 'api_v1.apps.ApiV1Config',
 'api_v2.apps.ApiV2Config',
 'meta.apps.MetaConfig',
 'posts.apps.PostsConfig',
 'users.apps.UsersConfig',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'rest_framework']
INTERNAL_IPS=[]
LANGUAGES=[...]
LANGUAGES_BIDI=['he', 'ar', 'fa', 'ur']
LANGUAGE_CODE='en-us'
LANGUAGE_COOKIE_AGE=None
LANGUAGE_COOKIE_DOMAIN=None
LANGUAGE_COOKIE_NAME='django_language'
LANGUAGE_COOKIE_PATH='/'
LOCALE_PATHS=[]
LOGGING={}
LOGGING_CONFIG='logging.config.dictConfig'
LOGIN_REDIRECT_URL='/accounts/profile/'
LOGIN_URL='/accounts/login/'
LOGOUT_REDIRECT_URL=None
MANAGERS=[]
MEDIA_ROOT=''
MEDIA_URL=''
MESSAGE_STORAGE='django.contrib.messages.storage.fallback.FallbackStorage'
MIDDLEWARE=['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware']
MIGRATION_MODULES={}
MONTH_DAY_FORMAT='F j'
NUMBER_GROUPING=0
PASSWORD_HASHERS='********************'
PASSWORD_RESET_TIMEOUT_DAYS='********************'
PREPEND_WWW=False
REST_FRAMEWORK={'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticatedOrReadOnly',),
 'PAGE_SIZE': 50}
ROOT_URLCONF='app.urls'
SECRET_KEY='********************'
SECURE_BROWSER_XSS_FILTER=False
SECURE_CONTENT_TYPE_NOSNIFF=False
SECURE_HSTS_INCLUDE_SUBDOMAINS=False
SECURE_HSTS_PRELOAD=False
SECURE_HSTS_SECONDS=0
SECURE_PROXY_SSL_HEADER=None
SECURE_REDIRECT_EXEMPT=[]
SECURE_SSL_HOST=None
SECURE_SSL_REDIRECT=False
SERVER_EMAIL='root@localhost'
SESSION_CACHE_ALIAS='default'
SESSION_COOKIE_AGE=1209600
SESSION_COOKIE_DOMAIN=None
SESSION_COOKIE_HTTPONLY=True
SESSION_COOKIE_NAME='sessionid'
SESSION_COOKIE_PATH='/'
SESSION_COOKIE_SECURE=False
SESSION_ENGINE='django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE=False
SESSION_FILE_PATH=None
SESSION_SAVE_EVERY_REQUEST=False
SESSION_SERIALIZER='django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE='app.settings.production'
SHORT_DATETIME_FORMAT='m/d/Y P'
SHORT_DATE_FORMAT='m/d/Y'
SIGNING_BACKEND='django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS=[]
SITE_ID=1
SITE_NAME='Super Cool Site'
SITE_TAGLINE="Super Cool Tagline."
STATICFILES_DIRS=[]
STATICFILES_FINDERS=['django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT='/app/static'
STATIC_URL='/static/'
TEMPLATES=[{'APP_DIRS': True,
  'BACKEND': 'django.template.backends.django.DjangoTemplates',
  'DIRS': ['/app/templates', '/app/templates/allauth', '/app/templates/errors'],
  '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',
                                     'quest.context_processors.template_constants']}}]
TEST_NON_SERIALIZED_APPS=[]
TEST_RUNNER='django.test.runner.DiscoverRunner'
THOUSAND_SEPARATOR=','
TIME_FORMAT='P'
TIME_INPUT_FORMATS=['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']
TIME_ZONE='UTC'
USE_ETAGS=False
USE_I18N=True
USE_L10N=True
USE_THOUSAND_SEPARATOR=False
USE_TZ=False
USE_X_FORWARDED_HOST=False
USE_X_FORWARDED_PORT=False
VERSION='1.0.0-alpha.2'
WSGI_APPLICATION='app.wsgi.application'
X_FRAME_OPTIONS='SAMEORIGIN'
YEAR_MONTH_FORMAT='F Y'
Jacob
  • 1,560
  • 4
  • 19
  • 41

1 Answers1

0

Try to run

$Heroku run python manage.py migrate

In your terminal.

Awesome Name
  • 117
  • 1
  • 8