Take this

Software Development / Web Development

Mastering Django Web Development

Explore and master the advanced features of Django to build professional, manageable web applications


About This Video

  • Take a look at the internal workings of class-based views and extend their functionality beyond the basics 
  • Unravel the finer mysteries of middleware that will help you to manage your database better than before 
  • Develop a basic CRUD foundation that will work with the available REST API clients for JavaScript, Android, and iOS 

In Detail

Django is one of the world's leading web development platforms that follows the model-view-template development method. This Python web framework makes your app building experience smoother, faster, and easier. It has been and continues to be the key feature behind the success of many start-ups across the world.

Mastering Django Web Development shows you how to use advanced concepts to help you build professional grade Django applications.

We start off by learning how class-based views work so that you can fully benefit from this powerful, but often poorly understood feature. We’ll then create custom middleware which will help us better organize frequently used code. 

Have you ever wanted to build a complete REST API? We’ll do just that, starting out with a basic read-only API and then adding key-based authentication to allow the full range of CRUD functionality. We’ll also utilize model managers and the Q method so that we can make it easier to get the data we need to our views and clients.

For the finishing touches, we’ll dive into the details of caching, to improve our application performance, and then add custom management commands to help us automate routine tasks.

By the end of this video course, you will emerge a Django expert.

Full details


  • Advanced Uses of Class-based Views
    The Course Overview
    This video will provide an overview of the course.
    Extending Class-based Views
    Generic class-based views provide a lot of functionality. Let's take a look at how you can easily extend them to create your own custom solutions. • Extend DetailView with your own data in three lines of code • Go further to add custom context with just a little more code • Reuse or even extend your new custom views
    Using Mixins
    The built–in, generic class-based views are actually made up of many reusable mixins. Take a look at how you can use the same technique to add your own behaviors into your class-based views. • Understand how DetailView is made from several mixins • Create a new-style Python class with the behavior we want • Include your mixin when creating a custom class-based view
    Custom Class-based Views
    You don't have to use generic class-based views. If you plan to override much of the built-in behavior or just don't need it, then you can start out with a simpler class, such as view. • Learn how the View class adds the very basic functionality needed for a view • Add methods corresponding to the RESTful verbs, such as get and post • Use the views in the same way that you would use a generic class-based view
    Creating a Switchboard View
    You can create a single class-based view that can handle all of the operations for a set of data. These are sometimes called switchboard classes, and they can help make your code easier to maintain. • Start out with a class based on the View object • Python's getattr function can call different methods based on parameters • Create a method for each operation of your switchboard
  • Custom Middleware
    What Is Middleware?
    Code that is used in many views can be moved into middleware, allowing it to operate either before or after your view code is executed. • Process the Request and Process view hooks to run before your view • Make Process Template Response and Process Response run after your view • Get Process Exception running if there is an unhandled exception
    Creating a Custom Middleware
    Middleware classes are not fancy; they simply have one or more methods that correspond to one of the five predefined hooks available. Let's take a closer look at them here. • Decide which hooks your middleware should implement • Create a standard- or new-style class • Define a method corresponding to the hooks you want
    Exception Handling Middleware
    Showing users exceptions is unprofessional and may be a security problem. Let's examine an easier way to create middleware that catches and responds to unhandled exceptions. • Create a class and add it to middleware • Define a process_exception method • Capture and process exceptions before they get to the user
  • Custom Template Tags and Filters
    Creating Template Filters
    In this video we will explore the possibility of creating custom filters to make frequently used behaviors easily reusable for everyone on our team. • Create a submodule of templatetags • Register your filter with the register.filter decorator • Include your custom filter on any template that uses it
    Creating Custom Template Tags
    If you need a functionality that is too sophisticated for a filter, it should be a template tag. These are of several kinds, such as simple_tag for basic functionality and a template inclusion tag to bring in entire templates. • Create a submodule of templatetags • Register your template tag with the register.simple_tag decorator • Include your custom tag on any template that uses it
  • Building a Rest API
    Using Tastypie to Create a REST API
    With the growing popularity of Angular.js and similar tools, more applications need to provide a RESTful API. Tastypie is a Python module that does most of the work for us. Let's check it out. • Install the Django-tastypie module • Use the Resource or ModelResource modules to autogenerate an API from your data • Activate your URLs to get a basic read-only API
    Complex Queries with Our API
    Sometimes you want to modify the data before it goes out to the API. Tastypie makes it easy to add or customize the data returned from the API. • Take a look at how the tastypie dehydrates functionality and serializes our data • Customize the dehydrate process to add custom fields • Inspect the data in the API to check whether your changes were made
    Authentication and CRUD Support
    Not all applications work with a read-only API. Sometimes, you want full CRUD support from your API. You need to add an authentication step before you make this functionality available. Fortunately, Tastypie does all of this for us. • Enable ApiKeyAuthentication and run a migration • Create a key for a user and add an authorization header to your request • Enjoy full support of get, post, patch, and delete
  • Advanced Databases Modeling
    Generic Relationships
    Sometimes, you want to combine data from different models. It's not hard to do this with Python, but generic relationships allow Django to do this for you. • Include the ContentType and GenericForeignKey modules • Define a model that has GenericForeignKey • Ensure that the GenericForeignKey keys are all the same datatype
    Formsets for Data Management
    Have you wished you could add or edit many records to the database at once? With only a few lines of code, you can add this capability to your application. • Check out formsets that are based on the FormView class • Use modelformset_factory as a form class • Modify form as a list in our template
    Advanced Queries with Q()
    Django's ORM works fine when your filters are combined using the AND operator. If you want to perform more complicated queries, you should use the Q function, which just gives you more flexibility with your logic. • Understand the use of & or | to combine filter options with AND or OR • Use parentheses to get the proper logical operations • If you need more power, use the raw function and SQL
  • Caching for Optimum Performance
    Low-level Caching
    Is your application running slow? You may be performing expensive operations more often than necessary. We can use low-level caching operations to have tight control over our application's performance. • Enable caching using memcached, redis, or your database • Take a look at how cache.get and cache.set allow you to set and retrieve cached data • Use database caching during development and another style in production
    Caching with Middleware
    Do you have data that is accessed on many views? We already know we can create middleware to reduce duplication, but why not add caching at to middleware to also speed up performance? • Create a middleware that responds to the process_request hook • Use cache.get to check whether your data is cached • Fetch your data and add it to the request
    Using the Template Cache
    If your cache needs are simpler, you can perform caching at the template level. This can provide a tremendous improvement in performance and is easy to use. • Load the cache template tag in templates that need it • Wrap the cache tags to specify the data to be cached and an expiration • Consider a frontend cache, such as Varnish, to further speed up parts of your site
  • Management and Maintenance of Your Application
    Model Managers
    Do you frequently perform the same query and filter operation in multiple views? Avoid duplication using model managers. • Models already have a manager called objects • Override objects with your own manager to add custom functionality • Add new methods for each of your frequently used filters
    Using a Model Manager to Create New Objects
    You may have a similar logic in multiple areas of the site to deal with inserting data. You can create a manager function that accepts your data as a parameter and centralizes your insertion logic. • Create a method on your manager that accepts your data • Perform the validation according to your rules • Model manager methods can access related fields
    Creating manage.py Commands
    Do you perform regular maintenance on your application? You can simplify periodic cron tasks by creating custom manage.py commands. • Create a module called management • Create a submodule called commands, which is a manage.py command • Improve the performance of your apps as well as reduce problems caused by code duplication


  • Django
  • Django Rest Framework (DRF)

Similar Courses

More Courses by this Instructor