Update django.md

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

@ -333,41 +333,40 @@ db_from_env = dj_database_url.config(conn_max_age=600) # add this
DATABASES['default'].update(db_from_env) # add this
```
create `Procfile` and add
We need to set up static files correctly for heroku. Edit `django_rest_api/settings.py` at the top to import `os`:
```
web: gunicorn django_rest_api.wsgi
```python
from pathlib import Path
import dj_database_url
import os # add this
```
This will help heroku know how to build your app
Create `Pipfile` and add
and now edit the bottom of the same file:
```python
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # add this
```
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
Now install gunicorn which will serve your django code
[packages]
django = "*"
psycopg2-binary = "*"
django-extensions = "*"
djangorestframework = "*"
dj-database-url = "*"
python-dotenv = "*"
gunicorn = "*"
whitenoise = "*"
django-cors-headers = "*"
```
python -m pip install gunicorn
```
[requires]
python_version = "3.9.1"
create `Procfile` and add
```
web: gunicorn django_rest_api.wsgi
```
**Note:** on the last line, substitute your version of python (`python --version`)
This will tell heroku how to serve your app
This will tell heroku what packages it needs
Now run the following to create a dependencies list for heroku:
```
python -m pip freeze > requirements.txt
```
### On the Browser
@ -377,7 +376,6 @@ This will tell heroku what packages it needs
### 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`

Loading…
Cancel
Save