Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Building & Consuming REST APIs in Python with Django
Rating: 3.8 out of 5(20 ratings)
147 students

Building & Consuming REST APIs in Python with Django

Build professional REST APIs with Django and integrate it with React
Last updated 1/2019
English

What you'll learn

  • Set up your own application project in Django
  • Organize your Django project development and production environment
  • Write Django views and use routes to handle incoming requests
  • Create your own Django templates for your Python web API and learn to use template filters and tags
  • Work with RESTful APIs in Django
  • Quickly build clean APIs with the Django REST Framework
  • Design the user interface of your application using React components
  • Integrate Django APIs with your React frontend to build a bookmarking application

Course content

2 sections37 lectures5h 11m total length
  • The Course Overview3:46

    This video gives an overview of this section.                       

  • The Bigger Picture3:46

    In this video, we look at a demo of the final product after the  three sections, including a templated Django response and browsing a  Django REST Framework API.                         

    • Look at HTML response

    • Look at REST API server

     

  • Your Development Environment7:24

    In this video, we will install Python, Django and the Django REST Framework onto our development computer                         

    • Install Python 3 based on the Operating System of our computer. Create a Virual Environment

    • Use Pip to install Django and the Django REST framework

    • Use pip requirements.txt to identify installed python components in a development environment

     

  • Installing PostgreSQL6:30

    In this video, we will install PostgreSQL, create a new database and configure Python support                         

    • Install PostgreSQL into our development environment

    • Use Psql to check our installation and create a new database

    • Use pip to install PostgreSQL support into Python

     

  • Django Projects and Apps4:15

    In this video, we will create a new Django project and then create an application within that project.                         

    • Create a project directory and use django-admin startproject

    • Use manage.py startapp to create a Django application

    • Review Django external application publishing guidelines

     

  • Using the Django Development Environment6:59

    In this video, we will use the development environment we have  setup in previous videos to show the Django initial success web page.                         

    • Introduce settings.py and configuring our database

    • Highlight the DEBUG flag and placing sensitive information in settings.py

    • Use Django’s development webserver via the manage.py runserver command and seeing the Django initial default page

     

  • MVC and MVT Framework7:29

    This video gives an overview of MVC and MVT Framework.                         

    • Look at the concept of MVC and MVT Framework.

    • Look at Django models

    • Look at Django template

     

  • Creating and Working with Models9:35

    In this video, we will discuss Django models, create our first model, create methods on our models and test them.                         

    • Introduce Django model and how relationships between Models can be used.

    • Create a Django model

    • Create methods on Django models and test them

     

  • Migrations and Database Queries10:56

    In this video, we will apply migrations to our Django models,  which keep our database structure up to date. We will perform queries on  our database.                         

    • Consider what Django migrations are and have Django create schema migrations

    • Consider what data migrations are and create one, and then apply all migrations created so far in this video

    • Perform some simple queries against our database

     

  • Writing Our First View10:40

    In this video, we will create a simple “Hello World” view,  consider Django class based views, perform URL configuration and add a  parameter to our view.                         

    • Discuss Django class based views and use view to create a simple view that returns a hard coded response

    • Perform URL configuration or routing at  both the Project and App level to make our new view accessible. Access  the view in a browser

    • Make use of URL querystring and kwarg parameters. Discuss the pros and cons of each approach

     

  • Routing and HTTP Methods11:16

    In this video, we will discuss how Django handles requests,  Django’s URL routing, matching URLs with path and re_path and HTTP  methods.                         

    • Discuss how Django handles requests from  the request in to middleware, then URL config, then view and then the  reverse for the response

    • Review URL configuration from previous video and discuss use of path() and re_path()

    • Cover methods (verbs) of Http Requests including Get and Post requests. How Http methods then translate to class methods

     

  • Using Templates15:25

    In this video, we will cover Django Templates and the  TemplateView. We will cover Django’s template inheritance system, how to  pass data to templates, where to place template files and template tags  and filters.                         

    • Explain how hardcoded responses are undesirable. Introduce Django’s TemplateView

    • Learn about using base templates and view  specific templates that extend base templates. Learn how to make data  available within templates.
      Review template settings in settings.py and see our first set of templates in action

    • Explain how templates should not perform core logic, however we can use template tags and filters to perform presentation logic

     

  • Testing13:08

    In this video we will consider why we should test, the core tools  Django provides for testing, how to configure PostgreSQL for testing and  some integration and unit tests.                         

    • Learn how we need to use automated testing tools and how we can write test cases that place our code under test

    • Make use of pqsl to configure PostgreSQL for testing

    • Develop Integration tests that make use of the Django test client.
      Develop unit tests that test specific view functions using a RequestFactory as well as class attributes

     

  • Exploring RESTful APIs5:06

    This video gives an overview of the entire section and then  considers what is an API, what is REST, REST resources, methods and CRUD  operations and HTTP Status codes.                         

    • Explain the difference between traditional web responses and API responses. Learn how REST provides an API on HTTP

    • Learn what Resources, HTTP Methods and CRUD operations are

    • Explain how a result of an API request is communicated via a status code

     

  • Writing a Simple Hello World API4:29

    In this video, we will create an API end point by configuring a  URL endpoint for a view that generates JSON output. We will also accept  input and perform simple validation.                         

    • Make use of a URL pattern configuration to give access to our API view

    • Define a View using the base View class that uses JsonResponse to return an API response

    • Include in our View definition  validation of a name parameter and return an error if this is equal to  fred. Show results in a browser

     

  • Exploring the DRF7:00

    In this video, we will discuss why we use the DRF, what key parts  of the DRF are, who uses it and the web browsable API feature of the  DRF.                         

    • Learn how the DRF helps us in providing code that we would otherwise have to provide ourselves many times over

    • Learn what the key parts of the DRF are,  including serializers, DRF views, routers and authentication and  permissioning. Learn how these relate to CRUD operations

    • Explore who uses the DRF and see the web browsable feature of the DRF

     

  • Serializing Models8:43

    In this video, we will learn about DRF serializers. We will first  look at manually defining a serializer and then use ModelSerializer to  base a definition on an existing model.                         

    • Review our existing models with focus on the Bookmark Model, then we will define a serializer with create and update methods

    • Using the Python console, we will create  some initial data in the database and then demonstrate what our  serializers do with this data along with simulated received data

    • We will define a serializer based on Bookmark using a ModelSerializer.
      We will then demonstrate how this serializer can be used with a list of Bookmarks in the Python console

     

  • Refactoring Our API with the DRF8:27

    In this video, we will combine our learnings from the previous two  videos with DRF views by building a Bookmarks list and a Bookmarks  detail view.                         

    • Learn about basic DRF view URL configuration, including format suffixes.
      Define a Bookmark List view that can build a list and create new Bookmarks

    • Learn about basic DRF detail view URL  configuration. Define a Bookmark detail view that can get detail, update  a Bookmark and delete a Bookmark

    • Watch a demonstration of all of the  functionality previously developed in this video, including listing  existing Bookmarks, creating new Bookmarks, updating existing Bookmarks  and deleting them.

     

  • Generic Django REST Framework Views6:10

    In this video, we will replace our views from the previous video  by exploiting pre-built functionality of the DRF for common CRUD  operations.                         

    • Make use of ListCreate-APIView for Bookmark listing and new Bookmark creation

    • Make use of RetriveUpdate-APIView for Bookmark detail queries, updating a Bookmark and deleting a Bookmark

    • Take advantage of the ModelViewset that combines all the functionality seen earlier in this video in one convenient package.

     

  • Extra Viewset Actions and Routers7:57

    In this video we will use DRF routers to clean up our URL configuration and create a specialised API action.                         

    • Learn about  Hyperlinked-Model-Serializers and how they can create related links in  our API. Significantly simplify our URL configuration with a DRF router

    • Create a specialised viewset action that  can add a like to a Bookmark. Learn how to define this in the viewset  and ensure the DRF router is aware of it. See how it is accessed from  the browser

    • Consider each of the view strategies covered in this and previous videos and scenarios where each would be the best fit

     

  • Testing the API10:30

    In this video we will consider how we can use DRF automated testing tools to perform integration and unit tests of our API.                         

    • Learn how to write an integration test of a DRF based viewset and place different actions under test

    • Learn how to write a unit test of  specific methods of a DRF based viewset, how to isolate dependencies via  patching and using mocks to test each operation of the code

    • See how the Django test runner is used in combination with DRF test tools

     

  • Test Your Knowledge

Requirements

  • Working knowledge of Python is required.

Description

One of the best things about Python is that it fits well into any web developer skill set. With the help of Django, Python’s high-end web framework, you can rapidly develop your own websites and build web APIs that are clean and easy to maintain, all while allowing you to integrate your Python code with powerful JavaScript frameworks. If you are a web developer who wants to build full-stack Python apps by creating APIs in Django and then integrating it with React, a frontend JavaScript framework, then go for this course.

This comprehensive 2-in-1 course is a step-by-step tutorial which is a perfect course to create and learn the use of Django REST APIs to make fully-functioning Python applications. You will first set up the development environment for your application. You will then build the backend of your application by creating RESTful APIs in Django. Next, you will learn to build and use React components for designing the UI of your application, and work with React code’s data and state to determine the behavior of it. Finally, you will learn to integrate your Django RESTful APIs with the React frontend to build a complete bookmarking application.

Contents and Overview

This training program includes 2 complete courses, carefully chosen to give you the most comprehensive training possible.

In the first course, Building REST APIs with Python, you will delve into key aspects such as code reusability, deployment, and maintaining your application. You will learn production server configuration and bundle technologies with Python along with React to provide an end-to-end web development solution. You will learn to create REST APIs in Django.

In the second course, Consuming Python APIs with React, you will start by quickly setting up your JavaScript tools and Node.js, as well as React.js for building a bookmarking application project. You will then put together your basic frontend code for interacting with your Django backend. You will also learn to build and use React components for your application's UI, and work with your React code's data and state to determine how your application behaves. Next, you will explore routing and event handling for your application. You will delve into backend interaction details, such as authentication for login. Finally, you will learn to consume your Django resources and also create, update, and delete item data. Alongwith, you will  also learn specific tasks such as managing your bookmarks and counting and collecting likes and comments on your bookmarks.

 By the end of this course, you will be able to build your RESTful APIs using Django and integrate it into your projects with ease.

About the Authors :

Wayne Merry:
CPA Work Experience:
- Financial Controller HOPE worldwide Australia (Development and benevolence charity) 2013-2017 and consultant to HOPE worldwide Papua New Guinea
- Investment manager Mimas Lapetus Trust 2005-2012
- General Manager Merry's Specialties 2003-2004
- Trading Systems project lead Bourse Data 1998-2003
- Industrial Systems manager United Weighing Australia 1995-1998
Education:
- BA App Sci (Computer Technology) 1991-1994
- Masters of Entrepreneurship and Innovation (Hnrs) 2004-2008
- Masters of Professional Accounting and Masters of International Finance (2010-2012)
Interests:
- Bush Search and Rescue 2009 (developed GPS field training software using Django—first used 2011, and still in use)
- Third-world charity program implementation, reporting, and management
- He works too hard to listen to much music, but he loves listening to techno while programming in Django!

Who this course is for:

  • This course is for Django developers who want to have a taste of real-world full-stack development, integrating a Python backend with a React frontend.