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 4. Create CRUD Web Application

Chapter 4. Create CRUD Web Application

Building a CRUD Web Application in Django

In this chapter, we'll explore how to create a basic CRUD (Create, Read, Update, Delete) web application using Django. We'll guide you through key concepts like views, URL dispatchers, templates, and settings to build dynamic web applications that interact with a database.

What We Cover in This Chapter

The following topics are covered in this chapter:

CRUD Web Application

In this section, we’ll introduce the core idea of CRUD, which stands for Create, Read, Update, and Delete. These are the fundamental operations of a web application, allowing users to interact with and modify data stored in a database.

Basic CRUD Structure in Django

This part will show you how to structure a simple CRUD application in Django. You’ll learn how to set up models, views, and templates to handle the four CRUD operations effectively.

Django Generic Views

In this section, we’ll explore Django’s generic views, which simplify the creation of views for common tasks. We'll focus on five key generic views: ListView, DetailView, CreateView, UpdateView, and DeleteView.

How To Write Class-Based Views with Generic Views

This topic will show you how to write class-based views (CBVs) using Django’s generic views. We’ll walk through the process of defining a class-based view, customizing it, and using attributes like model, template_name, and context_object_name.

Generic View Basic Attributes

In this section, we’ll cover the basic attributes of Django’s generic views, such as model, queryset, template_name, and others, to customize the behavior and appearance of your views.

URL Dispatcher for CRUD Views

Learn how Django’s URL dispatcher works to map HTTP requests to the appropriate views. This section will guide you through creating URL patterns for your CRUD views and using path converters like <int:pk> for dynamic URL matching.

Django Templates for CRUD Views

Explore how Django templates are used to display data for CRUD views. You'll learn how to create templates for list pages, detail pages, and forms for create, update, and delete operations.

Django Template Language (DTL)

This section introduces Django Template Language (DTL), a powerful templating system that allows you to embed dynamic content in your HTML templates. You’ll learn about variables, filters, and template tags that make it easy to generate dynamic content in your views.

Template for List Page

Here, we'll focus on designing a template for the list page, where you can display a list of objects fetched from the database. We’ll discuss how to iterate over a list of objects using the {% for %} loop in Django templates.

get_FOO_display method

We’ll cover the get_FOO_display method, which allows you to convert model field choices into human-readable values, making your templates more user-friendly.

Template for Detail Page

This section explains how to create a template for the detail page, where you display information about a specific object from the database. Unlike the list page, the detail page displays a single record.

Template with Model Relations

Learn how to handle model relations in Django templates. This section explains how to display data from related models using the ForeignKey and ManyToManyField relationships in your templates.

Template for Create and Update Page

In this section, we will show you how to create templates for the create and update pages, which allow users to submit data using HTML forms. We’ll cover form handling and how to use Django’s form tags to display forms on these pages.

Template for Delete Page

Learn how to create a confirmation page for deleting records in this section. We’ll show you how to create a form for the delete operation and how to display a confirmation message for the user.

Add Links – {% url %} tag

We’ll explain how to use the {% url %} tag in Django templates to generate links to different views in your application. This tag helps with reverse URL resolution and ensures that URLs are generated dynamically based on the URL name.

Extend Templates – {% extends %} tag

Learn how to create a base template that can be extended by other templates using the {% extends %} tag. This approach helps in avoiding repetition of common page structures like headers, footers, and navigation bars.

Check Developing App UI on Mobile Device

This section explains how to test your web application’s UI on mobile devices. You’ll learn how to configure Django to make your app accessible on mobile devices using local IP addresses.

Django Templates with Bootstrap

We’ll show you how to integrate Bootstrap with Django templates to create responsive and attractive user interfaces for your CRUD views. Learn how to use Bootstrap’s pre-built components and utilities to enhance your web design.

Crispy Forms

In this section, we’ll explore how to use the Crispy Forms package to style Django forms with Bootstrap, making your form templates more attractive and user-friendly.

Customize Views (1) – Change List Order

We’ll demonstrate how to customize your views to change the order of records displayed on the list page. Learn how to use the order_by method to sort your querysets based on different fields.

Customize Views (2) – Filter Lists

Learn how to filter lists based on specific criteria using the filter method. This section shows you how to display filtered data based on user inputs or predefined conditions.

Context

Learn how to pass context data from your views to templates. This section will help you understand how Django’s context system works and how to use it effectively in your views and templates.

Customize Views (3) – Add Extra Context

In this section, we’ll demonstrate how to add extra context to your views by overriding the get_context_data method. This allows you to pass additional data to your templates, such as the current date or other dynamic information.

Modularize Templates – {% include %} tag

Learn how to modularize your templates by using the {% include %} tag. This tag allows you to reuse template fragments, such as headers, footers, or sidebars, across multiple templates.

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

This section explains how to serve static files, such as images, CSS, and JavaScript, in your Django development environment. We’ll cover the {% static %} tag and how to link static files in your templates.

STATIC_URL and STATICFILES_DIRS

Learn how to configure static files in Django using the STATIC_URL and STATICFILES_DIRS settings. This section will help you manage static files for both development and production environments.

Create Index HTML

In this section, we’ll walk you through the process of creating an index page for your Django project. You’ll learn how to structure the URL patterns and define a view for the home page, making it accessible to users when they visit your site.

Learn offline for better focus!
A book for this course is available on Amazon.

Django Visual Guide

Step-By-Step Manual for Complete Beginners to Mastering Django, Python, and Web Development.

Your browser does not support the video tag.
Get the Book Now

More Topics to Explore

Defining Django Views: Function vs. Class-Based

Create Views

Defining Django Views: Function vs. Class-Based

Create Views

Tags:

Web Application

Django

CRUD

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