33👍
Just had this problem too. I did the following to solve it: (assuming you’re in project dir)
rm -rf .git
git init
git add .
git commit -m "First commit"
heroku create --stack cedar
git push heroku master
A slightly involved solution to create a new application, but at least it works. Hope that helps!
- How to send success message if we use django generic views
- How to display the message passed to Http404 in a custom 404 Error template in Django?
- Django's get_current_language always returns "en"
- How to setup SysLogHandler with Django 1.3 logging dictionary configuration
- Django HTML E-mail template doesn't load css in the e-mail
8👍
I had a similar issue and in my case was because my apps were outside of my project folder. Heroku expects to have this structure:
Procfile
requirements.txt
static/
myproject/
manage.py
app1/
app2/
..
3👍
rm -rf .git
git init
git add .
git commit -m "First commit"
heroku create --stack cedar
git push heroku master
This worked for me as well !
- How to I hide my secret_key using virtualenv and Django?
- Django: default language i18n
- What is the right way to use angular2 http requests with Django CSRF protection?
- Django i18n: how to not translate the admin site?
2👍
Since Django is a python app, you’ll need to have requirements.txt
and setup.py
sit in the root of your repo and not the src sub-directory. See https://github.com/heroku/heroku-buildpack-python/blob/master/bin/detect
- Django Testing – Hard code URLs or Not
- Appropriate choice of authentication class for python REST API used by web app
- How to get values of all object fields in Django?
- How can I disable a model field in a django form
2👍
My stupid error was to mispell requirements.txt
as the erroneous requirments.txt
. I didn’t need setup.py
.
Additionally I need to actually store the git repository in Github. Just creating it locally wasn’t enough.
- How to send success message if we use django generic views
- Could not import 'oauth2_provider.ext.rest_framework.OAuth2Authentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'
2👍
For everyone deleting their Git history to make this work… the only reason that works is because the initial commit in the new repository contains the necessary files for Heroku to recognize your app.
I ran into this problem because I added the Procfile
and requirements.txt
for my app and tried to push to Heroku before actually committing them. So when I pushed to Heroku, I wasn’t pushing those files!
Making a commit with all the necessary files and then pushing should solve this problem, and is vastly preferable to deleting your entire Git history.
Hope this helps!
- Getting the request origin in a Django request
- Paypal monthly subscription plan settings for first day of the month and making monthly recurring payment – django python
- Django: WSGIRequest' object has no attribute 'user' on some pages?
- Where are the files downloaded using pip stored in virtualenv?
- Can't login to Django /admin interface
2👍
I struggled with this issue for a long time and the only solution was Vincent van Leeuwen’s, but I didn’t understand why. The problem turned out to be that I was working from a local branch other than master. So when I was running
git push heroku master
I was actually pushing
(local) master->(heroku) master
and not
(local) current_branch -> (heroku) master
as I intended. This failed because my local master branch didn’t have requirements.txt, Procfile, etc.
The solution is:
git push heroku current_branch:master
See heroku docs for more.
Hope this helps.
- How to get object from PK inside Django template?
- Deploying Django (fastcgi, apache mod_wsgi, uwsgi, gunicorn)
- How do I use perform_create to set a field automatically in Django Rest Framework?
- (gcloud.app.deploy) Error Response: [7] Access Not Configured. Cloud Build has not been used in project
1👍
Heroku needs a requirements.txt file, which helps Heroku know what dependencies need to be installed for your Django project. You can use a tool generate your requirements.txt file.
Run in command line
pip freeze > requirements.txt
which will create a requirements.txt file with all your installed packages, such as Django, django-registration, etc…
This link may be helpful: http://tutorial.djangogirls.org/deploy/README.html
- Django runserver custom database
- Show images in Django templates
- Django model inheritance and type check
- How to get object from PK inside Django template?
- Django update on queryset to change ID of ForeignKey
1👍
My situation is that my codes are needed to save both on Github and Heroku, if I use the following solution, rm -rf .git
will delete the connection to my Github, therefore I can’t push my codes to Github.
rm -rf .git
git init
git add .
git commit -m "First commit"
heroku create --stack cedar-14
git push heroku master
Instead, my solution is as follows:
$ heroku create
$ heroku config:add BUILDPACK_URL=git://github.com/heroku/heroku-buildpack-python.git
$ git push heroku master
- Django create new user without password
- Django GROUP BY field value
- How to purge all tasks of a specific queue with celery in python?
- Performance, load and stress testing in Django
0👍
All the above solutions dont mention that what matters is where is your .git initialised. Actually when you try push on heroku you should be doing it from the directory where you had initialsed the git itself.
Also the directory you are uploading should be the one where you have files like
-
requirements.txt, Procfile, virtualenv, manage.py and .gitignore
etc.
In short Heroku needs all files to understand the type of project you want to upload so these files should be accessible on the root directory.
- Accessing Django OneToOneField in templates?
- Django queryset filter GT, LT, GTE, LTE returns full object list
- Why does python new york time zone display 4:56 instead 4:00?
- (gcloud.app.deploy) Error Response: [7] Access Not Configured. Cloud Build has not been used in project
- Pass a query parameter with django reverse?
-1👍
You need to add the requirement.txt file to git and then push it will work of sure.
- Django: How to keep the test database when the test is finished?
- How to print pretty JSON on a html page from a django template?