Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

Django IntroductionChapter 6. Deploy Django App

Overview of Django App Deployment (2)

Overview of Django App Deployment (2)

Decision Making in Django App Deployment

In app deployment, there are many choices you need to make. For example:

  • Which hosting service are you going to use?
  • On which OS do you want to deploy your app?
  • Which database are you going to use for production?
  • Which combination of the web server and application server are you going to configure?

In this chapter, we'll explain the app deployment processes with specific case examples addressing the questions above.

Hosting Service

The first choice you need to make is which hosting service you want to use. There are different types of hosting services and providers.

For hosting services, the traditional approach was using a rental server; however, it is getting less popular now. Cloud services or VPS (Virtual Private Server) have recently become more popular as you don't need to worry about technical infrastructure management.

There are further different types of cloud services. For example, PaaS (Platform as a Service) like Vercel, Firebase, or PythonAnywhere provides easy-to-use services. IaaS (Infrastructure as a Service) like AWS, Azure, or GCP (Google Cloud Platform) provides more customizable services. Usually, cloud services use a pay-per-use billing model.

VPS is a service similar to IaaS, but its billing scheme is usually fixed price.

In this chapter, we'll use AWS Lightsail, which is a VPS service provided by AWS. It offers a three-month free trial.

OS

You need an OS (Operating System) to run a Django application. Linux OS is the most popular OS for web servers. Linux OS has many distributions, such as Ubuntu, CentOS, Debian, and Fedora. In this chapter, we use Ubuntu OS (20.04 LTS). You need basic knowledge of Linux OS to deploy your Django app on Linux OS. If you want to learn it, please check our Linux Introduction course.

Linux IntroductionLinux Introduction

Database

The default database for Django is SQLite, which is free open-source database software. It is a lightweight and serverless database, mainly used in small to medium-scale applications. It can be used at the production stage, but MySQL or PostgreSQL are more popular for production use. You can also use cloud database services. In this chapter, we use PostgreSQL

Web Server and Application Server

Two types of server functionalities are required for dynamic web applications – web server and application server. The key difference between those two servers is that the web server manages static content while the application server handles dynamic content.

Depending on the server software, the application server functionality can be part of web server software. For example, for Apache, which is popular web server software, the application server functionality is covered by an extended module. On the other hand, another popular web server, Nginx, focuses more on web server functionalities.

In this chapter, we use Nginx for a web server and Gunicorn for an application server.

For the application server functionality, Django supports two standard interfaces: WSGI (Web Server Gateway Interface) and ASGI(Asynchronous Server Gateway Interface). Gunicorn is a WSGI server.

Summary

Here is the summary of software and service choices for our Django app deployment in this chapter.

  • Hosting Service: AWS Lightsail
  • OS: Ubuntu (20.04 LTS)
  • Database: PostgreSQL
  • Application Server: Gunicorn
  • Web Server: Nginx

For the virtualization approach, we continue to use Python venv. Using Docker has recently become an alternative and more popular approach. We'll explain how to deploy a Django app using Dockar in another course.


You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Overview of Django User Management Functions

Overview of User Management Functions

Managing Static Files in Django Production

Static File Settings

Setting Up SSH Remote Connection for Deployment

Hosting Service Initial Settings (2) – SSH Remote Connection

Overview of Django User Management Functions

Overview of User Management Functions

Managing Static Files in Django Production

Static File Settings

Setting Up SSH Remote Connection for Deployment

Hosting Service Initial Settings (2) – SSH Remote Connection

Tags:

VPS

AWS

App Deployment

Google Cloud Platform

IaaS

PaaS

Azure

Linux OS

Django Introduction
Course Content

Chapter 1. Django Key Concepts

Web Framework and Django

Websites vs. Django Web Apps

How Django Handles HTTP Request and HTTP Response

Django's MVT Framework

Django Templates vs. Django APIs

Chapter 2. Django Quick Start Guide

Install Python

Install Visual Studio Code

Create Project Directory

Set Up Virtual Environment

Install Django

Start Django Project

Run Server

Database Migration

URL dispatcher – urls.py

Create Superuser and Log In to Django Admin

Start App

Create HTML Templates

Create Views

Add URL Patterns

Project vs. App

Chapter 3. Django Models and Databases

Create a Database in Django

Relational Database

Create Django Models

Makemigrations and Migrate

Add Models in Django Admin – admin.py

Change Display Name of Record Objects

Django Models – Data Field Type

Django Models – Field Options

Django Models – Help Text Option

Django Models – Choices Option

Django Models – DateField with datetime Module

Django Models – Relationship Fields

Django Models – ID

Django Models – ForeignKey (OneToMany Relationship)

Django Models – OneToOneField

Django Models – ManyToManyField

Chapter 4. Create CRUD Web Application

CRUD Web Application

Basic CRUD Structure in Django

Django Generic Views

How To Write Class-Based Views with Generic Views

Generic View Basic Attributes

URL Dispatcher for CRUD Views

Django Templates for CRUD Views

Django Template Language (DTL)

Template for List Page

get_FOO_display method

Template for Detail Page

Template with Model Relations

Template for Create and Update Page

Template for Delete Page

Add Links – {% url %} tag

Extend Templates – {% extends %} tag

Check Developing App UI on Mobile Device

Django Templates with Bootstrap

Crispy Forms

Customize Views (1) – Change List Order

Customizing Views (2) – Filter Lists

Context

Customize Views (3) – Add Extra Context

Modularize Templates – {% include %} tag

Static Files in Development Environment – {% static %} tag

STATIC_URL and STATICFILES_DIRS

Create Index HTML

Chapter 5. User Management

User Authentication

Overview of User Management Functions

User Management Function Development with Django

Approaches to Building User Management Functions in Django

Django Allauth (1) – Introduction

Django Allauth (2) – Installation and Initial Settings

Django Allauth (3) – Email Verification via Console

Django Allauth (4) – Email Verification via Gmail

Django Allauth (5) – Social Login with GitHub

Django Allauth (6) – Social Login with Google

Django Allauth (7) – Allauth Template File Setup

Django Allauth (8) – Add Basic Styling with Bootstrap and Crispy Forms

Django Allauth (9) – Customize Sign-in and Sign-up Pages

User Models

Login Required – LoginRequiredMixin

User Login Status Icon on Navigation Bar

Chapter 6. Deploy Django App

Overview of Django App Deployment (1)

Overview of Django App Deployment (2)

Key Steps of Django App Deployment

Hosting Service Initial Settings (1) – AWS Lightsail setup

Hosting Service Initial Settings (2) – SSH Remote Connection

Manage Local Computer and Remote Server Simultaneously

Tips for Managing Local Development and Remote Production Environment

Hosting Service Initial Settings (3) – Clone Project Directory with GitHub

Production Database Setup

Django Production Settings (1) – Settings.py for Development and Production

Django Production Settings (2) – Production Settings

Django Production Settings (3) – django-environ and .env file

Static File Settings

Django and Dependency Installation on Production Server

Web Server and Application Server in Django

Application Server Setup – Gunicorn

Web Server Setup – Nginx

Domain Setup

SSL Setup – Certbot

Email Setting – SendGrid

Social Login for Production

Manage Local Development and Remote Production Environment

Chapter 1. Django Key Concepts

Web Framework and Django

Websites vs. Django Web Apps

How Django Handles HTTP Request and HTTP Response

Django's MVT Framework

Django Templates vs. Django APIs

Chapter 2. Django Quick Start Guide

Install Python

Install Visual Studio Code

Create Project Directory

Set Up Virtual Environment

Install Django

Start Django Project

Run Server

Database Migration

URL dispatcher – urls.py

Create Superuser and Log In to Django Admin

Start App

Create HTML Templates

Create Views

Add URL Patterns

Project vs. App

Chapter 3. Django Models and Databases

Create a Database in Django

Relational Database

Create Django Models

Makemigrations and Migrate

Add Models in Django Admin – admin.py

Change Display Name of Record Objects

Django Models – Data Field Type

Django Models – Field Options

Django Models – Help Text Option

Django Models – Choices Option

Django Models – DateField with datetime Module

Django Models – Relationship Fields

Django Models – ID

Django Models – ForeignKey (OneToMany Relationship)

Django Models – OneToOneField

Django Models – ManyToManyField

Chapter 4. Create CRUD Web Application

CRUD Web Application

Basic CRUD Structure in Django

Django Generic Views

How To Write Class-Based Views with Generic Views

Generic View Basic Attributes

URL Dispatcher for CRUD Views

Django Templates for CRUD Views

Django Template Language (DTL)

Template for List Page

get_FOO_display method

Template for Detail Page

Template with Model Relations

Template for Create and Update Page

Template for Delete Page

Add Links – {% url %} tag

Extend Templates – {% extends %} tag

Check Developing App UI on Mobile Device

Django Templates with Bootstrap

Crispy Forms

Customize Views (1) – Change List Order

Customizing Views (2) – Filter Lists

Context

Customize Views (3) – Add Extra Context

Modularize Templates – {% include %} tag

Static Files in Development Environment – {% static %} tag

STATIC_URL and STATICFILES_DIRS

Create Index HTML

Chapter 5. User Management

User Authentication

Overview of User Management Functions

User Management Function Development with Django

Approaches to Building User Management Functions in Django

Django Allauth (1) – Introduction

Django Allauth (2) – Installation and Initial Settings

Django Allauth (3) – Email Verification via Console

Django Allauth (4) – Email Verification via Gmail

Django Allauth (5) – Social Login with GitHub

Django Allauth (6) – Social Login with Google

Django Allauth (7) – Allauth Template File Setup

Django Allauth (8) – Add Basic Styling with Bootstrap and Crispy Forms

Django Allauth (9) – Customize Sign-in and Sign-up Pages

User Models

Login Required – LoginRequiredMixin

User Login Status Icon on Navigation Bar

Chapter 6. Deploy Django App

Overview of Django App Deployment (1)

Overview of Django App Deployment (2)

Key Steps of Django App Deployment

Hosting Service Initial Settings (1) – AWS Lightsail setup

Hosting Service Initial Settings (2) – SSH Remote Connection

Manage Local Computer and Remote Server Simultaneously

Tips for Managing Local Development and Remote Production Environment

Hosting Service Initial Settings (3) – Clone Project Directory with GitHub

Production Database Setup

Django Production Settings (1) – Settings.py for Development and Production

Django Production Settings (2) – Production Settings

Django Production Settings (3) – django-environ and .env file

Static File Settings

Django and Dependency Installation on Production Server

Web Server and Application Server in Django

Application Server Setup – Gunicorn

Web Server Setup – Nginx

Domain Setup

SSL Setup – Certbot

Email Setting – SendGrid

Social Login for Production

Manage Local Development and Remote Production Environment