Take this
course

Software Development / Web Development

Learning Django Web Development

Leverage the simplicity and power of Django to build database-backed web applications with amazing speed

Description

Forget working with long, boring lines of code! With Django at your command, make the most of your time by building professional grade web applications in minutes. With the help of a suite of useful and time-saving tools, reduce or eliminate the work needed for the most common tasks to create highly functional and flexible apps.


Learning Django Web Development will help you build a solid foundation for constructing your own web applications as quick as it gets.


Start off by installing Django and initializing your project. Analyze Django’s in-built admin interfaces and utilize them to handle your application content. Furthermore, manage the data using generic views and auto-generated forms. With that, create an authentication system for your app by using login forms and finally walk through the process of deploying your application to the web.


Towards the end of the course, you’ll know everything there is to know from creating your app to deploying it with the help of the invaluable features of Django.

Full details

Curriculum

  • Introducing Django
    The Course Overview
    Learn about the benefits of Django and how it helps developers work more efficiently. • What is Django? • How does Django help developers • We'll build a social media website that demonstrates the characteristics of most web apps
    2:49
    Installing Django and Creating Our Project
    To begin using Django for development, you need to install the tools required. Learn the best way to install Django and then create your first project. • Django is a free software and can be downloaded from the Internet • Using a virtual environment will help you manage your projects over time • Create your first project and see how Django works on your computer
    3:02
    Understanding Apps
    Django makes it easy to reuse your code by separating it into apps. In fact, many features we'll use in this series are separate apps that we'll include in our project. • We'll create our first app, which includes database models and views • Our project also uses the admin interface, which is a separate app included with Django • Now we have a working project with a fully functional admin interface
    3:46
    Creating Our Models
    A model is a simple description of the data you want to store. Some projects may need nothing more than a model. • Model information is stored in an app's models.py file • Each field in the model definition corresponds to a type of data in the database • Adding a line of code to admin.py activates this model so that it can be used in the admin interface
    5:00
    Using the Built-in Admin Interface
    The admin interface allows you to manage users, groups, and all the data stored in your database. • The model definition allows you to search, sort, add, edit, and delete information stored in the database • We can customize the admin.py file in order to control which fields will be shown in the admin area • We can make a few small changes to our models in order to get more detailed views in the admin area
    2:49
  • Using Generic Views
    What Are Views?
    Views allow you to create web pages for your application. These pages can be plain HTML or can load data from your database. • We define which pages, or views, our site will have in urls.py • A view can be a simple function or a Python class • We'll create a simple view to show a home page for our app
    3:20
    Using Django Templates
    Templates in Django can be standard HTML, XML, or plain text. This makes them simple to use for developers and designers. • Django expects templates to be stored in a certain place. If we're careful with the naming, this can make it easy to manage our app if it grows large in the future • We can use HTML or plain text in our templates • Python variables and simple logic can be used in our templates easily using special tags
    4:04
    Generic Display Views
    Many of the web pages follow a common pattern: show simple HTML, show a list of records in the database, or show details about one record. Django's generic views simplify these common tasks. • Our home page should show a list of records from the database • We can use the IndexView generic view to do this with almost no code • By subclassing the view, we can have more control over how it works
    5:55
    Template Inheritance and Parent Templates
    Many of the web pages in your app share common components. We can use template inheritance to move these common pieces into a separate file in order to avoid repeating ourselves. • Django has one of the best template systems that combines both power and simplicity • We can create a parent template that all pages inherit from • By separating our templates into multiple blocks, we can create optional regions in our parent template
    5:12
  • Authenticating Users
    The User’s Model
    Django includes a simple but customizable authentication system that makes it easy to drop in a user database to your app. • Users have roles, such as staff, super user, or just plain old user; additional roles and groups can be added • We'll create a contributor user account that has no access to the admin area • We can simply add login and logout capabilities using add-on apps included with Django
    6:00
    Changing Our Models
    It's quite common that your database structure will change over time. Django makes this easy with database migrations. • We'll make a change in our model in order to add a relationship for users • Django provides a command that identifies the changes and creates the necessary code to update the database • Database migrations are just simple Python and you can edit them to deal with special cases, if you need
    3:46
    Creating a Custom Profile
    Nearly every application that has users needs to add custom fields to the user profile. Django provides tools to make this easy. • We can create a new model that has a one-to-one relationship to the users model • We'll update the admin.py definition for our model in order to allow the editing of the profile in the admin area • The admin interface updates itself to show the additional profile fields
    3:30
    Generic Form Views
    Some apps simply need to show user information from the database, but it's quite common to give users a way to add and change data. Django provides generic views for this very purpose. • We can use the CreateView generic view in order to allow users to add data to the database • We'll subclass the EditView generic view to enable the editing of data • The urls.py file uses regular expressions to simplify the creation of views
    3:58
  • Investigating Performance
    Enabling the Django Debug Toolbar
    The Django Debug Toolbar is an add-on app created by the Django community, which helps to look at what your web app is doing behind the scenes. • Download the Django Debug Toolbar to your virtual environment • Enable the new app in your settings.py file • Reload your website and review the amazing amount of details about the internals of your app
    1:02
    Understanding Related Data
    Django optimizes itself to do lazy loading, where data is loaded only when it's needed. In some common scenarios, this actually hurts performance. There is an easy solution though. • Notice that for 20 database records, we perform 21 database queries • Lazy loading causes a potential performance problem by doing n+1 queries • By using the select_related property of our database query, we can force a join, which greatly speeds up our app
    1:53
    Customizing Our Home Page View's Query
    Generic Views can be subclassed and customized to enhance functionality. We'll use this capability to improve performance. • Our IndexView generic view is already extending the get_queryset method • We can add select_related to our lookup in order to force a join • Performance improved by over 40%, and the difference will be probably greater in a production environment
    1:34
  • Deploying Our App
    Introducing WSGI
    The Python community has created a standard called WSGI to deploy Python apps to the Web. It is compatible with many different kinds of servers. • Several PaaS cloud solutions are available, some for free, including OpenShift and Heroku • Deploying to your own server or VPS is common • We'll use a Linux server and the uWSGI library to deploy our app
    1:33
    Understanding Deployment
    Preparing our application for the Web involves a few simple steps in order to make it suitable for use in production. • We'll need to disable the debug mode before publishing to the Web • Static files, such as CSS can be bundled using the built-in collectstatic feature of Django • We'll use Git to get our application to the server, but FTP, SSH, and other methods can be used as well
    3:19
    Deploying Our Application
    In this example, we'll use Apache, uWSGI, and Django on an Ubuntu server. This stack is well supported and easy to use. • Configure Apache to serve static files directly without the need for Django • Create an ini file to tell uWSGI about our application • Restart Apache and uWSGI to see the app live
    1:59
    Wrapping Up
    We've covered a lot of ground in a short time, which is possible because Django includes many time-saving capabilities. • The Django documentation is top notch and provides tutorials as well as easy-to-read and follow instructions • Python's philosophy of "batteries included" has been carried over to Django, which has helped speed up this project • We've used the admin area, generic views, authentication, and the debug toolbar to create our web app
    1:37

Skills

  • Database
  • Django

Similar Courses

More Courses by this Instructor