Test-Driven Development with Django, Django REST Framework, and Docker

Learn how to build, test, and deploy a Django app with Docker, Pytest, and Django REST Framework!

"Code without tests is broken by design." - Jacob Kaplan-Moss

Learning Objectives

By the end of this course, you will be able to:

Develop a RESTful API with Python, Django, and Django REST Framework Practice Test-Driven Development Test a Django app with Pytest Containerize Django and Postgres inside a Docker container Run unit and integration tests with code coverage inside a Docker container Create a custom User model in Django Implement an API with Django REST Framework Views and Serializers Check your code for any code quality issues via a linter Configure GitLab CI for continuous integration and deployment Speed up a Docker-based CI build with Docker Cache Deploy Django, Gunicorn, and Postgres to Heroku with Docker Manage static assets with WhiteNoise Create a production Dockerfile that uses multistage Docker builds Document a RESTful API with Swagger/OpenAPI and Core API Parameterize test functions and mock functionality in tests with Pytest Run tests in parallel with pytest-xdist

Tools and Technologies

Python Django Docker Postgres Pytest Django REST Framework Gunicorn Coverage.py flake8 Black isort HTTPie GitLab Heroku WhiteNoise Swagger/OpenAPI

Prerequisites

This is not a beginner course. It's designed for the advanced-beginner -- someone with at least six months of web development experience. Before beginning, you should have some familiarity with the following topics. Refer to these resources for more info:

Looking for a solid introduction to Django? Check out Django for Beginners. Highly recommended!

Demo

Info

Current version: 2.0.0

Last updated: April 15th, 2020

Author: Michael Herman

What will you learn?

Part 1

In this first part, you'll learn how to develop a RESTful API with Python, Django, Django REST Framework, and Postgres. You'll containerize Django and Postgres to run inside Docker containers and configure Pytest in order to practice Test-Driven Development (TDD).

Part 2

In the second part, you'll start by deploying Django, Gunicorn, and Postgres to Heroku with Docker. You'll then continue to build out the RESTful API as you write unit and integration tests. Finally, we'll look at how to document the API with Swagger.