Update django.md

main
Matt Huntington 5 years ago committed by GitHub
parent 5536b00a77
commit b4b7950ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save