Blargian
Blargian

Reputation: 350

Django Heroku deployment - ! [remote rejected] master -> master (pre-receive hook declined)

There are a few posts with this particular issue however I've tried about five or six different suggestions from those posts and have had no luck.

When trying

git push heroku master

I get the following error:

(env) PS C:\Users\Shaun\Desktop\DjangoBlog\src> git push heroku master
Total 0 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to murmuring-dusk-96030.
remote:
To https://git.heroku.com/murmuring-dusk-96030.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/murmuring-dusk-96030.git'

From the build log on the Heroku website:

-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
       More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
 !     Push failed

I have a simple static website running Django 2.2.3 as back end. I've been developing in a virtual environment on my local machine and have the following project structure shown blow, where src/ was what I renamed the folder created by the django-admin startproject command.

File directory structure

I'd like to deploy my site on Heroku so I've signed up, installed Git and the Heroku CLI. In my terminal I've logged in to Heroku and initialized my Git repository in this top level root (src/). I've added a Procfile which contains the following:

web: gunicorn blog.wsgi --log-file -

I have the following in my runtime.txt file. I'm actually running 3.7.3 in my virtual environment but I've tried both ways:

python-3.6.1

To settings I added:

import django_heroku

MIDDLEWARE = [
    # added this:
    'whitenoise.middleware.WhiteNoiseMiddleware',
]

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

#  Add configuration for static files storage using whitenoise
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

django_heroku.settings(locals())

My requirements.txt contains all packages I'm using and psycopg2, whitenoise and gunicorn, django-heroku.

I'm not sure what I'm doing wrong exactly, any help would be appreciated.

Upvotes: 0

Views: 1068

Answers (1)

Chris
Chris

Reputation: 136880

Your requirements.txt, along with your Procfile and runtime.txt, must be in the top-level root directory of your project.

Move them there, commit that change, and deploy again, e.g.

cd $PROJECT_ROOT
git mv src/requirements.txt .
git mv src/Procfile .
git mv src/runtime.txt .
git commit -m 'Move requirements.txt and Heroku files to root'
git push heroku master

Upvotes: 3

Related Questions