I am following this instruction to run my django project locally
https://devcenter.heroku.com/articles/getting-started-with-python#run-the-app-locally
When I type heroku local web, it says "[FAIL] No Procfile and no package.json file found in Current Directory - See run-foreman.js --help".
However, my project is a Django/python app and I don't have package.json.
But my project does have requirements.txt and Procfile in the root directory of my web application. What should I do?
Thanks
Related
I uploaded my website project on Heroku cloud a while ago and I needed to edit some stuff with the project and when I reupload the website again in the same app directory I get the message from Heroku that says Application error then I tried to create a new app directory in Heroku by command: create heroku appname
and when I upload my project doesn't work again with the different directory on Heroku so what is the step I missed here?
I followed up this lesson https://www.youtube.com/watch?v=MoX36izzEWY&t=1707s step by step and I don't know what the step I missed or what is may the new in Heroku didn't exist in this tutorial?
- I did create a virtual environment
- I did create all files that Heroku needs like:
ProcFile
pipfile
requirements.txt
and I installed everything as the tutorial said exactly: (gunicorn, django-heroku, whitenoise and so else)
last note:
I'm on Linux Ubuntu
I found the answer:
I had to install gunicorn into PipFile file side by side requirements.txt file
so, for the future coders, this is my mistake you have to install gunicorn into two files and they are: requirements.txt and PipFile
for Pipfile file you have to run the following command:
- $ pip3 install pipenv
- $ pipenv install gunicorn
Note that:
These commands run on the Linux system.
I am deploying a Django website on Heroku. My project is called mysite-project which contains at its root manage.py and Procfile
I can visit the heroku website after I run git push heroku master.
And the website shows:
I am assuming I do not see anything (navbar, initial page, etc.) because I did not run migrate.
If I do:
heroku run python manage.py migrate
I get the error:
python: can't open file 'manage.py': [Errno 2] No such file or directory
Which makes no sense since I am in the right directory.
In fact:
I can run python manage.py runserver and locahost works
git ls-files manage.py --outputs--> manage.py
BUT
If I do:
heroku run bash
ls manage.py
I get:
ls: cannot access 'manage.py': No such file or directory
It seems that manage.py is in my local but not in my heroku.
Procfile
web: gunicorn mysite-project.wsgi
First use heroku logs --source app --tail to make sure that the Build succeeded.
If the build is successful, make sure you have your project at the root of the git repo.
I had the same problem because my Django project was not at the root of the git repo.
My file hierarchy was first like (assuming the name of the project prototype and it has one app named app)
├──git_repo
├──Procfile
├──requirements.txt
├──new_folder
├──prototype (folder)
├──app (folder)
├──.gitignore
├──manage.py
├──db.sqlite3
I changed the hierarchy to the following and it worked
├──git_repo
├──Procfile
├──requirements.txt
├──prototype (folder)
├──app (folder)
├──.gitignore
├──manage.py
├──db.sqlite3
The welcome you see when you visit the site (as well as the fact, that you can't find manage.py with ls on the server) tells you, that you haven't successfully pushed your django project to Heroku yet. Try and run git push heroku master.
It may be that the push has failed, in which case you should consult the documentation. Specifically, run
$ pip install gunicorn django-heroku
$ pip freeze > requirements.txt
...and then add
import django_heroku
django_heroku.settings(locals())
...to the bottom of settings.py. Also don't forget to set STATIC_ROOT='staticfiles' in settings.pyaswell.
That screenshot attached indicates you have just created app in heroku but not pushed your local repository code to heroku app.
git push heroku master
I was getting this error too!
I solved it by specifying the path:
python <your_project_name>/manage.py migrate
This worked for me.
In my case, it was because I was using a branch name other than master. My branch name was heroku_branch, so to make things work properly, I pushed it this way
git push heroku heroku_branch:master
It was pushed this time and worked fine.
For django + heroku
web: python manage.py runserver 0.0.0.0:\$PORT
New to Django, I am trying to view the website with its associated functionality generated by the project files here:
https://github.com/tomwalker/django_quiz
When I use the usual: manage.py runserver on the command prompt, it says that there is no manage.py file, and there isn't.
Worryingly, I followed the instructions for installation which suggested: Run pip install -r requirements.txt
...and my computer proceeded to de-install Django 2.0? What is that about, and can anyone explain how to restore settings if I messed them up completely.
The second part of the instructions for installation asks to change something in the INSTALLED_APPS and urls.py section, but where? There is nothing in the root directory and it doesn't specify which folder/app to do this in?
I don't quite understand how to "run" (see/view) these files and see this quiz app in process on my local host. What do I need to add? Why is the manage.py file not included?
Any explanation or something to point me in the right direction would be appreciated
The github project contains only Django apps. Not whole project. You need to integrate this in your Django project. You can run it by following below steps.
Create New Django Project
Clone github repo in your project. Run following commands in your project directory.
git clone https://github.com/tomwalker/django_quiz.git
mv django_quiz/* .
rm -rf django_quiz
Add essay, true_false, quiz, multichoice in your installed apps
Install requirements with pip install -r requirements.txt
Create Migrations
Run Migrations
Add url(r'^q/', include('quiz.urls')) in your project urls.
Run server with python manage.py runserver
I have an django project (RESTful API written using Django Rest Framework) which uses the Postgres database.
I have a local git repository of the project and also I have it on my github account, and I want to deploy the porject to heroku.
In the official heroku tutorials, they don't show anything about how to prepare your app to deployment - (requirements file, settings file, Proc File, maybe more stuff that I don't know - which I saw in different tutorials that you need to do).
At the moment I only have the django app without any added file.
My question is - what do I need to do to prepare my app to deployment to heroku? as I said at the moment I have a local git repository and its also on Github.
Thanks!
1) Create a file called Procfile (no extension) in your project root with the following inside:
web: gunicorn APP_NAME.wsgi (replace APP_NAME with your app's name).
2) Pip install gunicorn and dj-database-url
3) In your virtual env terminal, run pip freeze > requirements.txt in your project root (do this every time you pip install any new packages).
4) In your production settings file, add the following to make your database work on heroku:
import dj_database_url
DATABASES['default'] = dj_database_url.config()
Note: This will cause errors in your local environment, so make sure you have a prod.py settings file as well (ask if you need an explanation).
5) Add heroku to your git settings via git remote add heroku git#heroku.com:HEROKU_APP_NAME.git (replace HEROKU_APP_NAME with your Heroku app name).
6) Once you do git add --all, git commit -m "SOME MESSAGE HERE" and git push, you can do git push heroku master.
I have already developed an application with Python Django and it's working, I am new to Python Django and now I need to deploy it on heroku servers, there are so many blogs and websites including heroku site that explains deploying a django app on heroku from scratch I haven't found any which talks about a running app
for example all of them need installing django which makes me confused,
this is the folder structure of my app:
myapp
|_my_app
| |_Settingd.py
| |_urls.py
| |_wsgi.py
|__webapp
|_statics(folder)
|_admin.py
|_models.py
|_views.py
The app is connecting to mysql server locally
Question(s):
Now I am totally confused, how do I have to deploy my running app on heroku? among the steps to deploy an app on heroku provided below which ones are mandatory for me and which ones I can escape and according to my folder structure where should be the location of requirements.txt or Procfile and what should be the content of them?
https://devcenter.heroku.com/articles/getting-started-with-django
Do I have to install virtualenv? and yes where should I run this command(in which folder)
I think I don't have to install django or any database api or driver for django? since they are all already installed
So the first question of yours is why the app should be running inside Virtualenv?
what's the first step? Install Django, right? Not quite. One common problem with installing packages directly to your current site-packages area is that, if you have more than one project or use Python on your machine for things other than Django, you may run into dependency issues between your applications and the installed packages. For this reason, we'll be using virtualenv to manage our Django installation. This is common, and recommended, practice among Python and Django users.
Then install and activate your virtualenv using this command...
$ virtualenv env
$ source env/bin/activate
And finally we activated the environment. Now it'll look like this
(env)rs#rajasimon-desktop:~/studio/Project$
Then i guess your second doubt what is the purpose to install django-toolbelt ?
If you are installing django-toolbelt it will install all the dependencies or package need.
it contains Django, psycopg2, gunicorn, dj-database-url, dj-static, static
Firstly Heroku natively uses postgres. Life will be easier for you if you use that locally.
If you really want to use mysql, you have two paths to follow.
1) Run mysql locally, but convert to postgres when migrating to Heroku using the mysql2psql gem, as described here: https://devcenter.heroku.com/articles/heroku-mysql
2) Use a mysql addon like https://addons.heroku.com/cleardb
However my recommendation would be to use postgres end to end, as it is baked into Heroku, and you'll be working with the default ways of using Heroku, not against the
This is my project package i am currenlty working
(env)ri#rajasimon-desktop:~/studio/project$ pip freeze
Django==1.6.5
MySQL-python==1.2.5
Pillow==2.5.3
argparse==1.2.1
django-ckeditor-updated==4.2.8
wsgiref==0.1.2
where should be the location of requirements.txt & Procfile ?
How to make requirements.txt file ?
By running below command will automatically include all packages inside txt file.
pip freeze > requirements.txt
Declare process type with Procfile
The procfile is for starting the dyno when in productioin. I always right like this..
web: gunicorn project.wsgi
So finally your project structure will look like this
myapp
|_my_app
| |_Settingd.py
| |_urls.py
| |_wsgi.py
|__webapp
| |_statics(folder)
| |_admin.py
| |_models.py
| |_views.py
|__manage.py
|__requirements.txt
|__Procfile