How to Deploy a Test-Ready Django Rest Framework Project to Heroku Using Gitlab-CI and PostgreSQL

Source: Avengers: Infinity War

First, Create the Heroku app.

Setup the PostgreSQL database for testing

Setup the Gitlab repository

Create your Django project

git clone <your gitlab repository URL here>
cd <your project directory>
python -m venv env
pip install -r requirements.txt
django-admin startproject <your_django_app_name> .

Create your test

python .\ startapp my_app_1

Configure and static folder

Configure .gitlab-ci.yml

DATABASE_URL=”$TEST_DATABASE_URL$SSLCONF” coverage run --branch --source=my_app1 test --keepdb
DATABASE_URL=”$TEST_DATABASE_URL$SSLCONF” coverage run --branch --source=my_app1,my_app2,my_app3 test --keepdb

Configure Procfile and

Configure .gitignore and setup.cfg


git add .
git commit -m "Initial commit"
git push origin master

Computer Science Undergraduate at University of Indonesia

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store