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:

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

Tools and Technologies

  1. Python
  2. Django
  3. Docker
  4. Postgres
  5. Pytest
  6. Django REST Framework
  7. Gunicorn
  8. Coverage.py
  9. flake8
  10. Black
  11. isort
  12. HTTPie
  13. GitLab
  14. Heroku
  15. WhiteNoise
  16. Swagger/OpenAPI

django tdd logo

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:

Topic Resource
Docker Get started with Docker
Docker Compose Get started with Docker Compose
Django Django Tutorial

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
  • AuthorMichael 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.




Table of Contents

Table of contents from Test-Driven Development with Django, Django REST Framework, and Docker:


Part 1
Part 2
  • Deployment
  • Code Coverage and Quality
  • Continuous Integration
  • Continuous Delivery
  • Remaining Routes
  • Pytest Monkeypatching
  • Advanced CI
  • API Documentation
  • Workflow
  • Structure
  • Next Steps

Get the full course:





Join our mailing list to be notified about course updates and new tutorials.