django-poetry-heroku is a project template for Django 3.1+ projects that are aimed to deploy at Heroku.
The project uses poetry
for python packaging and dependency manangement.
- Clone the repository into
<your_project_name>_project
git clone [email protected]:Thijss/django-poetry-heroku.git <your_project_name>_project
- Rename the folder
projectname
to<your_project_name>
cd <your_project_name>_project mv projectname <your_project_name>
- Review & update the info in
pyproject.toml
- Create and activate a virtualenv:
python3 -m venv .venv source .venv/bin/activate
- Install requirements with
poetry
:poetry install
In order to run the project, some environment variables need to be set.
This project uses django-environ
, which allows the use of a .env
file to set environment variables.
To get started, copy the example file:
cp .env.example .env
Afterwards, open the .env
file and change the file contents as you see fit.
You can find detailed descriptions of each variable in SETTINGS.
Make sure you've got a Heroku account and a working Heroku CLI:
Login to your account:
heroku login
Create your Heroku app:
heroku create <project_name>
Add required buildpacks for poetry
and python
:
heroku buildpacks:clear
heroku buildpacks:add https://github.com/moneymeets/python-poetry-buildpack.git
heroku buildpacks:add heroku/python
Add a database to your Heroku app:
heroku addons:create heroku-postgresql:hobby-dev --name=<your_project_name>-pg
In order to run the project, some environment variables need to be set (see SETTINGS).
heroku config:set DJANGO_SETTINGS_MODULE=config.settings.heroku
heroku config:set DEBUG=off
Generate and set a secret key
heroku config:set DJANGO_SECRET_KEY=<generated_secret_key>
Deploy your project:
git push heroku
You project should now be live!