1

I've been working locally on an AngularJS front-end, Django REST backend project and I want to deploy it to Heroku. It keeps giving me errors when I try to push, however,

I've followed the steps on here, which has helped me deploy Django-only apps before.

Below is the output from my heroku logs.

8" dyno= connect= service= status=503 bytes=
2015-04-11T20:51:24.680164+00:00 heroku[api]: Deploy efbd3fb by [email protected]
2015-04-11T20:51:24.680164+00:00 heroku[api]: Release v5 created by [email protected]
2015-04-11T20:51:25.010989+00:00 heroku[web.1]: State changed from crashed to starting
2015-04-11T20:51:30.109140+00:00 heroku[web.1]: Starting process with command `python manage.py collectstatic --noinput; gunicorn myApp.wsgi --log-file -`
2015-04-11T20:51:31.795813+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-04-11T20:51:31.795838+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-04-11T20:51:31.824251+00:00 app[web.1]: Traceback (most recent call last):
2015-04-11T20:51:31.824257+00:00 app[web.1]:   File "manage.py", line 8, in <module>
2015-04-11T20:51:31.824267+00:00 app[web.1]:     from django.core.management import execute_from_command_line
2015-04-11T20:51:31.824296+00:00 app[web.1]: ImportError: No module named django.core.management
2015-04-11T20:51:31.827843+00:00 app[web.1]: bash: gunicorn: command not found
2015-04-11T20:51:32.656017+00:00 heroku[web.1]: Process exited with status 127
2015-04-11T20:51:32.672886+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-11T20:51:32.672886+00:00 heroku[web.1]: State changed from crashed to starting
2015-04-11T20:51:36.675087+00:00 heroku[web.1]: Starting process with command `python manage.py collectstatic --noinput; gunicorn myApp.wsgi --log-file -`
2015-04-11T20:51:38.446374+00:00 app[web.1]: bash: gunicorn: command not found
2015-04-11T20:51:38.420704+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-04-11T20:51:38.420729+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-04-11T20:51:38.442039+00:00 app[web.1]:   File "manage.py", line 8, in <module>
2015-04-11T20:51:38.442033+00:00 app[web.1]: Traceback (most recent call last):
2015-04-11T20:51:38.443526+00:00 app[web.1]: ImportError: No module named django.core.management
2015-04-11T20:51:38.442047+00:00 app[web.1]:     from django.core.management import execute_from_command_line
2015-04-11T20:51:39.265192+00:00 heroku[web.1]: Process exited with status 127
2015-04-11T20:51:39.287328+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-11T20:52:10.960135+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=afbb960d-eae4-4891-a885-d4a7e3880f1f fwd="64.247.79.248" dyno= connect= service= status=503 bytes=
2015-04-11T20:52:11.321003+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myapp.herokuapp.com request_id=de3242f1-7dda-4cc5-8b35-6d7c77392151 fwd="64.247.79.248" dyno= connect= service= status=503 bytes=

It seems like Heroku is confused because of an ambiguity between which server to use (Node.js vs. Django) and can't resolve it. Django can't seem to be found by Heroku.

The basic outline of my project is based on this example: https://github.com/brwr/thinkster-django-angular.

My settings file is as follows:

"""
Django settings for my project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = SUPER_SECRET

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG', True)

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'debug_toolbar',
    'rest_framework',
    'compressor',
    'authentication',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'myApp.urls'

WSGI_APPLICATION = 'myApp.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

import dj_database_url

DATABASES = {
    'default': dj_database_url.config(
        default='sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3')
    )
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'

STATICFILES_DIRS = (
#    os.path.join(BASE_DIR, 'dist/static'),
    os.path.join(BASE_DIR, 'static'),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)

COMPRESS_ENABLED = os.environ.get('COMPRESS_ENABLED', False)

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'templates'),
)

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.SessionAuthentication',
    )
}

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Allow all host headers
ALLOWED_HOSTS = ['*']

AUTH_USER_MODEL = 'authentication.Account'


# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] =  dj_database_url.config()

# Enable Connection Pooling
DATABASES['default']['ENGINE'] = 'django_postgrespool'


# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

If any more information is needed, I can add it.

Thanks, erip

EDIT

I noticed this when pushing to Heroku:

Node.js

It definitely is being recognized as a Node.js backend rather than Django and is, therefore, not installing from my requirements.txt. How can I change this? I tried heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-python, but it didn't seem to work.

2
  • Do you have a requirements.txt file in the root directory of your project ? AFAIK, it's the criterion Heroku use to detect Python applications. Commented Apr 11, 2015 at 21:59
  • @niconoe Yes, there's a requirements.txt in the root. It was detecting both django and Node. Commented Apr 11, 2015 at 22:20

2 Answers 2

1

I don't understand why you need Node at all in a Django project - it's not required for Angular or DRF - but the instructions in the linked project mention setting the buildpack to a custom "multi" one:

heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
Sign up to request clarification or add additional context in comments.

1 Comment

I followed these instructions and got Push rejected, no Cedar-supported app detected
0

it seems like you have not installed Django in you virtualenv

Have you forgot to run pip install django-toolbelt

4 Comments

I already have django-toolbelt, but it seems like Heroku doesn't.
which version of django are you using?
I'm using Django 1.7.1
Have you got requirements.txt file?

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.