From b4b7950ea2e7d302c5f2db7ac1e1c482d1155dee Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Wed, 17 Feb 2021 16:41:27 -0500 Subject: [PATCH] Update django.md --- django.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/django.md b/django.md index 9e4d2cd..8c95632 100644 --- a/django.md +++ b/django.md @@ -286,3 +286,40 @@ CORS_ALLOW_ALL_ORIGINS = True # add this ``` ## Deploy to Heroku + +### In Terminal + +1. Create a heroku app from the root of your project folder, run: `heroku create` + + - The above command will randomly generate a name for you, if you want to name your app something specific run: `heroku create urlNameYouWantHere` + +1. Copy the heroku url that was created (without the `https://`), go to your `django_rest_api/settings.py` and add it into the `ALLOWED_HOSTS` + + - e.g. + + ![](https://imgur.com/AVlB8kK.png) + +### On the Browser + +1. Go to your heroku dashboard for the heroku project you just created +1. Click on Configure Add-Ons +1. Search for Heroku Postgres and add it + +### In Terminal + +1. run `heroku config:set DISABLE_COLLECTSTATIC=1` +1. `git add -A` +1. `git commit -m "heroku deployment"` +1. `git push heroku master` +1. Once it builds successfully, run `heroku run bash` +1. While in heroku bash, apply the migrations to the heroku project by running: `python manage.py migrate` +1. Still in heroku bash, create a superuser for the heroku project by running `python manage.py createsuperuser` and follow the prompts + - To exit heroku bash, run `exit` + +### In Browser + +1. After the migrations finish, you should now be able to open the heroku app in your browser to see the Django REST interface! + - Don't forget to go to `/api/contacts` +1. Remember that your heroku database is separate from your local database, so there should not be any data on the first load. + - You can add data by logging in with the heroku superuser you created +1. You can now use this deployed version as your backend API