Build a Backend REST API with Python & Django - Advanced
4.5 (2,249 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
11,218 students enrolled

Build a Backend REST API with Python & Django - Advanced

Create an advanced REST API with Python, Django REST Framework and Docker using Test Driven Development (TDD)
Bestseller
4.5 (2,249 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
11,218 students enrolled
Last updated 3/2020
English
English, French [Auto-generated], 3 more
  • Indonesian [Auto-generated]
  • Portuguese [Auto-generated]
  • Spanish [Auto-generated]
Current price: $139.99 Original price: $199.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 8 hours on-demand video
  • 5 articles
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Setting up a local development server with Docker
  • Writing a Python project using Test Driven Development
  • Building a REST API with advanced features such as uploading and viewing images
  • Creating a backend that can be used a base for your future projects or MVP
  • Hands on experience applying best practice principles such as PEP-8 and unit tests
  • Configure Travis-CI to automate code checks
Course content
Expand all 77 lectures 08:00:51
+ Introduction
6 lectures 08:42

You cannot run Docker on Windows 10 Home edition. This is because Windows 10 Pro or Enterprise is required in order to use Hyper-V which Docker uses for virtualization. If you happen to have Windows 10 Home, you have two options.

Preview 00:36
+ Installation and setup
2 lectures 01:33
System setup
00:37
Windows 10 Home Workaround
00:55
+ Create new project
5 lectures 22:25

Setup a new project using GitHub and clone to our local machine.

Preview 02:50

Create a new Dockerfile that we can use to build the image for our project.

Preview 09:56

Configure docker compose to run our project.

Preview 05:22
Custom configuration for Linux users
01:21

Create a new Django project using our docker compose file.

Preview 02:56
+ Setup automation
2 lectures 08:56

Login to Travis-CI and enable our project for automation.

Preview 01:41

Create a configuration file that tells Travis-CI how to run our unit tests and linting.

Preview 07:15

Test your Travis-CI knowledge

Travis-CI
1 question
+ Introduction to test driven development (TDD)
2 lectures 10:55

Write a very simple unit test to demonstrate the process of unit testing code using Django.

Writing a simple unit test
05:47

Write another very simple unit test, but this time we will follow the Test Driven Development (TDD) method.

Preview 05:08

Test your knowledge on Django Unit Tests

Django Unit Tests
1 question
+ Configure Django custom user model
6 lectures 30:17

Use the Django management script to create a new app within our project. The app will be called 'core' and it will be used to hold all code that is central to our project (such as database models and the admin page).

Create core app
02:52

Here we will create a custom user model for our project. The custom user model will replace Django's built in user model. The purpose of customising the model is to support handling registration and authentication using an email instead of username.

Add tests for custom user model
05:41

Implement the user model to make the tests pass.

Implement custom user model
10:23

Next we will implement a change to our custom user manager that ensures emails are normalized. Normalizing the email means ensuring the domain part is all lowercase.

Normalize email addresses
03:25

Here we will add an extra validation step to our create_user function, so it will raise a validation error if a blank or null email field is passed in. We do this so a correct error message is displayed when using this function.

Add validation for email field
02:36

Now we will add support for creating superusers using the create_superuser function on our custom user manager. The create_superuser function is used by the Django createsuperuser management command, so it's required for creating admin using the CLI, which we will be doing later in the course.

Add support for creating superusers
05:20

Test your knowledge on the Django custom user model

Django custom user model
1 question
+ Setup Django admin
4 lectures 24:41

Now we need to configure our Django admin to work with our custom user model. To do this, we need to make some modifications to the fields that Django displays in the default Django admin. In this video we setup the tests to test that our Django admin is working correctly.

Add tests for listing users in Django admin
09:30

Now we will modify the Django admin to support listing users from our custom user model. This should make the tests from the previous video pass successfully.

Modify Django admin to list our custom user model
02:27

Here we modify the Django admin to support changing the custom user model. We start by adding a test to ensure the 'user change page' loads successfully, then we implement the feature by modifying the fieldsets of the default Django UserAdmin class.

Modify Django admin to support changing user model
07:48

Finally we can modify our Django admin to support creating new users. We start by testing the create user page, and end by making the necessary modifications to the add_fieldsets variable in our UserAdmin class.

Modify Django admin to support creating users
04:56
+ Setting up database
3 lectures 14:00

Here we will prepare our docker-compose.yml for running PostgreSQL Database 10 as our application database. In this video we start the setup by setting some environment variables for authentication with the database, and also adding our db service.

Add postgres to docker compose
05:25

Before our docker container will support connecting to PostgreSQL, we need to make a few minor modifications. First we will add the psycopg2 package to our requirements.txt file, then we will update our Dockerfile to support installing and using the client for our application.

Add postgres support to Dockerfile
05:43

Now we can configure our database within the Django settings.py file. We will do this by updating the DATABASES settings and pulling in some environment variables.

Configure database in Django
02:52
+ Waiting for postgres to start
5 lectures 26:35

A common issue when using PostgreSQL with Django is that the application starts before the database. This causes it to fail with an OperationalError saying that the database is unavailable. To get around this, we will create a management command which we can use to delay starting our app until the database is up. We start by adding unit tests for our command. The unit tests will ensure the command works as expected when the database is and is not available.

Add tests for wait_for_db command
11:43

Now we have our tests failing, we can go ahead and make them pass by creating our wait_for_db command.

Add wait_for_db command
07:30

Finally we can update our docker-compose.yml file to run our wait_for_db management command before starting our app. While we are doing that, we will also add migrate to run our migrations when we start our docker container.

Make docker compose wait for db
02:51

Finally we can update our docker-compose.yml file to run our wait_for_db management command before starting our app. While we are doing that, we will also add migrate to run our migrations when we start our docker container.

Test in browser
03:01

Test your knowledge on mocking

Mocking
2 questions
Requirements
  • Basic knowledge of programming and building simple applications
  • Familiar with Django
  • Comfortable using command line tools (Terminal/Command Prompt)
  • macOS, Linux or Windows machine capable of running Docker (This excludes Windows 10 Home)
  • Positive attitude and willingness to learn!
Description

Welcome to the advanced course on how to Build a Backend REST API using Python, Django (2.0), Django REST Framework (3.9), Docker, Travis CI, Postgres and Test Driven Development!

Whether you’re a freelance programmer, tech entrepreneur, or just starting out building backends - this course will help lay the foundation of your knowledge base and give you the tools to advance your skills with some of the most in-demand programming languages today.

APIs are the unsung heroes behind the technologies that we all love and use religiously.

One of the most critical components for any tech-based business is an API. So knowing how to create an API from start to finish is a vital skill to have as a developer. You cannot build a successful app without a backend REST API!

In this course I’ll show you how to build an advanced API that handles creating and updating user profiles, changing passwords, creating objects, uploading images, filtering and searching objects, and more.

The best way to learn anything is to do it. So the practical application of the course -- the project that you’ll build along side me -- is an API. A recipe API, to be specific.

You will learn how to build an advanced recipe API that allows you to upload and store some of your favourite recipes from photos and the web.

You’ll learn how to create objects i.e. recipes with titles, price points, cooking times, ingredients and tags like “comfort food”, “vegan” or “dessert”. Think of it as a virtual recipe box.

By the end of this course you will have built a fully functioning REST API that can handle:

  • User authentication

  • Creating objects

  • Filtering and sorting objects

  • Uploading and viewing images

You’ll also learn, in detail how to:

  • Setup a project with Docker and Docker-Compose

  • Configure Travis-CI to automatically run linting and unit tests

  • Write unit tests using the Django Test Framework

  • Apply best practice principles including Test Driven Development  

  • Handle uploading media files with Django

  • Customize the Django admin

  • Configure a Postgres database

This course has one singular focus: To teach you how to create an advanced API from start to finish using best practice principles and Test Driven Development.

This course is NOT FOR YOU:

  • If you’re looking for a course to build an API, a front end, and deployment

  • If you’re looking to build 10 different apps in one course

  • If you want to learn lots of different technologies and approaches to app development in general

This is a hands-on course, with a bit of theory and lots of opportunities to test your knowledge.

The content is challenging but rewarding. Ready for it? Let’s dive in!

**PLEASE NOTE: You cannot run Docker on Windows 10 Home edition. This is because Windows 10 Pro or Enterprise is required in order to use Hyper-V which Docker uses for virtualization. To take this course you have two options. These are covered in Lecture 6, which is free to preview before purchasing the course.

Who this course is for:
  • Intermediate programmers who already have some understanding of Python and want to skill up
  • Developers proficient in other languages but looking to add Python to their toolkit