Reputation: 5198
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!
Upvotes: 0
Views: 309
Reputation: 7049
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 [email protected]: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
.
Upvotes: 1