Skip to content
/ django-poetry-heroku Public template

A project template for Django projects aimed to deploy at Heroku

License

Notifications You must be signed in to change notification settings

Thijss/django-poetry-heroku

Repository files navigation

Django-Poetry-Heroku

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.

Prerequisities

  • Python 3.6 or higher (link)
  • poetry (link)

Usage

  1. Clone the repository into <your_project_name>_project
    git clone [email protected]:Thijss/django-poetry-heroku.git <your_project_name>_project
  2. Rename the folder projectname to <your_project_name>
    cd <your_project_name>_project
    mv projectname <your_project_name>
  3. Review & update the info in pyproject.toml

Installation

  1. Create and activate a virtualenv:
    python3 -m venv .venv
    source .venv/bin/activate
  2. Install requirements with poetry:
    poetry install

Development

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.

Deployment (Heroku)

Make sure you've got a Heroku account and a working Heroku CLI:

Heroku app

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

Database

Add a database to your Heroku app:

heroku addons:create heroku-postgresql:hobby-dev --name=<your_project_name>-pg

Environment variables

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

Deploy your project:

git push heroku

You project should now be live!

License

MIT

About

A project template for Django projects aimed to deploy at Heroku

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published