Mastering Django: A Beginner's Guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Mastering Django helps the reader master the powerful Django framework for Python for creating dynamic applications and projects. Django is a high-level, open-source Python web framework created to help web developers achieve tight deadlines while also meeting a variety of needs. The primary feature of Django that makes it so popular among developers is that it promotes rapid development while providing a consistent and realistic design. Django is a complete toolkit with a basic code and highly adaptable architecture that promotes rapid development – it can shape and pace your web app concept and see it through to launch in a matter of hours. Django’s simplicity, stability, scalability, and flexibility are unmatched. It is currently a vibrant, collaborative, open-source project with thousands of users and contributors. Django is a versatile framework capable of developing any website. Hallmarks of this popular web framework include Robust design, rapid software development, fantastic documentation and tutorials, a vast community with readymade solutions, reasonably easy learning curve, and a high degree of clarity and readability. Django has carved out a niche for itself in the industry over the years, and appropriately so. Many popular apps use Django as their secret ingredient. Django has many features and can accommodate any modern web application. If you wish to build a successful career in web development, learning Django is a wise choice. With Mastering Django, learning the Django framework becomes a charm, and will help readers undoubtedly advance their careers. The Mastering Computer Science series is edited by Sufyan bin Uzayr, a writer and educator with more than a decade of experience in the computing field.

Author(s): Sufyan bin Uzayr
Series: Mastering Computer Science
Publisher: CRC Press
Year: 2022

Language: English
Pages: 321
City: Boca Raton

Cover
Half Title
Series Page
Title Page
Copyright Page
Table of Contents
Mastering Computer Science Series Preface
About the Editor
Chapter 1 Django’s History
Which Language Is Used in Django?
Is Python Necessary for Django?
What Can I Do with Python?
Is Python Supported?
Advantages of Python Programming Language
Before Django, Things Needed to Be Done in Python
How Do We Get Started with Python?
Coding Editors
Is Python an Interpreted or Compiler Language?
Applications of Python Programming
Additional Features of Python
Django
What Is a Web Framework?
Types of Web Framework
Advantages of Using Web Framework for Development?
How to Use Django Frameworks?
How Does Django Code Look Like?
The Model Template View (MTV) Design Pattern
Why Django Templates?
How Popular Is Django?
Why MTV Instead of MVC?
Why Django?
Advantages of Django
Disadvantages of Django
Difference between Project and App
Django File Structure
What Else Can You Do?
Setting Up a Database?
Main Topics
Chapter Summary
Chapter 2 Installation
So Firstly, What Is IDE?
Why Do Developers Use IDEs?
Understanding the Differences: Local IDE vs. Cloud IDE
What Is a Local IDE?
Benefits
What Is Cloud IDE?
Benefits
Are You New to Django?
Learning Django
Database Driver
Why Is Python Required?
Python Installation on Windows
How to Add PATH in Environment Variable
Verifying
Python Interpreter
What Is a PIP?
Installing PIP on Windows
PIP Commands
Setup Python Virtual Environment
Why Use Virtual Environments?
Organizing Folders
Freezing Requirements
Command for using the Virtual Environment
Installing Django with PIP
Install Django from Local tar​.​gz File with PIP
Install Django from Git
Installing and Creating the Django Project
How to Change the Default Port?
How to Check the Django Version?
Template File
Creating a Project and Deploying
Deploying with Heroku
Chapter Summary
Chapter 3 File Structure
Examining the Project Structure and Apps
Exploring the Project Folder
Manage​.​py
Middleware
Types of Middleware
Custom Middleware
How to Create Middleware?
Middleware Methods
urls​.​py
URL Mapping
Most Commonly Used Django URL Functions
views​.​py
wsgi​.​py
asgi​.​py
Exploring the App Folder
Migration Folder
models​.​py
urls​.​py
tests​.​py
Files and Directories to Create
Django Commands
Create a Project’s Directory Structure
Create New App in Project
Run the Server
Create Database Migration
Migrate the Database
Create Admin User
Create Admin User Git Bash
Django Is a Loosely Coupled Framework
Django's URL Configuration
Additional Configuration
URL Dispatcher
Chapter Summary
Chapter 4 Django’s Model
Fundamentals of Django’s Model
Different Types of Fields
How Do Django Models Work?
What Is Fields Option?
Field Options
Explanation
Adding Model String
What Is Unicode Object?
Magic method or Dunder Method
Relationships and Query Set
Relationships
Many-to-Many Relationships
Retrieving Single Object from QuerySets
Filtering the Records
Using exclude() Method
Ordering Data
Chaining Lookups
Slicing Data
Many-to-One Relationships
Some Important Field Lookups
One-to-One Relationships
Why Do We Use Models?
Configuring the Database
Types of Database
Connecting to Database
Modelformsets
The Admin Module
Installing the Admin Module
Chapter Summary
Chapter 5 Django’s View
Views in Django
Configuration of the URLs
Mapping URLs to Views
How Does It Process a Request?
What Is URL Routing?
What Is path vs. re_path?
How to Create Views
Adding a Homepage Path
Function-Based Views
Class-Based Views
What are generic views?
Types of Generic View
Django View HTTP Decorators
URLconfs and Loose Coupling
Django Exceptions and Error-Handling
What Are Exceptions?
Exception in Python
Why Practice Exceptions?
Common Exception
Explanation
Raising Exceptions
Custom Exceptions
Django Exceptions
URL Resolver Exceptions
Advanced View and URLs
Using Named Groups
Keyword Arguments vs. Positional Arguments
Passing Extra Options to View Functions
Chapter Summary
Chapter 6 Django’s Templates
Basics of Template
Jinja
Why Is Jinja2 Useful?
Origin of Jinja2?
API
Why do we need Jinja2?
Installation
Dependencies
What Is Babel?
Template
Django Template System Basic
Operators
Other Operators
Python in-built Method
Various Functions
Comparisons
Logic
Rendering a Template
The Django Template Language
Why do We Use Engine?
What Are Loaders?
Support for Template Engines
Configuration or How Django Finds the Templates?
Common terms used in TEMPLATE
Creating a Site Template
Addition Path for Template
Full Example of Templates
Class Jinja
Usage of Template Loaders
Optional Argument
Template Inheritance
Django Static Files Handling
Chapter Summary
Chapter 7 Django’s Admin Panel
Overview of Django Admin
Accessing the Django Admin Site
Enabling Admin Panel
What Does Admin Do?
How Does It Work?
How Secure Is Django Admin?
Writing Action Functions
Usage
Various Subcommands
Django Admin Customization
Python manage​.​py Startapp Products
How to Register/Unregister Models from Admin?
Customization of Heading in Admin Panel
Django Admin Custom Page Layout, Data, and Behaviors
Model Admin Classes
How to add Jquery in you project?
Chapter Summary
Chapter 8 Django’s Forms
HTML Forms
Link to a Page with the Form
Input Tag
Django’s Role in Forms
Django’s Forms
forms.Form vs forms.ModelForm
The Django Form Class
Bound and Unbound Form Instances
Widgets
The form class
Widgets Argument
Django-crispy-Forms
How to Use Django Crispy Forms
Crispy Filter
Installation
Load in the Crispy Form Tags
Using the Django as_crispy_field Form Filter
What to Do When the Crispy Form Is Not Working?
Template Packs
How to Style Django Forms with Bootstrap
Form Helpers
Django UserCreationForm
Implement Django UserCreationForm
The Reason Why We Use self.cleaned_data
Understanding Args and Kwargs in Python
What Are Args?
What Are Kwargs?
Use of Args and Kwargs
Using Both Args and Kwargs in a Function
Chapter Summary
Chapter 9 The Advanced Model
Django Model Definition
Fields
Common Field Arguments
Fields for Common Data Types
Importing the model​.​py in Various Files
Various Advanced Topics in Django Models
Model Method
Creating New Instances
Customizing Model Loading
Deleting Objects from Database
Model.get_deferred_fields()
Validating Objects
Model.clean_fields(exclude=None)
Model.validate_unique(exclude=None)
Saving Objects
Auto-incrementing Primary Keys
Model​.​pk vs Model​.​id
Model Objects
Saving ForeignKey and ManyToManyField Fields
Retrieving All Objects
Other model instance methods
UserModel
User Model Built-in Fields
Methods
Logout and Login Signals
Manager Methods
Model Manager
A Custom Name to the Default Manager
How to Use the Student Manager
Methods of Manager Class
Chapter Summary
Chapter 10 Deployment
Introduction
Prerequisites
What Is a Deployment Environment?
Python Installation on Windows
How to Add PATH in Environment Variable
Installing Django with pip
Creation of the Django Project
Choosing the Right Hosting Provider
Ready to Publish Your Website
Django Deployment Interfaces
WSGI
ASGI
class Application
AWS?
What Is Cloud Computing?
Types of Clouds
Cloud Services Models
AWS Services
AWS Elastic Beanstalk
Benefits
Open the ES environment in the browser
Accessing Django Admin in Deployment
Collect the Static in the CLI
Check the Django Web App from AWS
Azure
Features of Cloud-Based Services
Microsoft Azure Features Related to Mobile Services
Deploying Our Django App onto Azure
File Structure
Installing Azure
Azure Deployment Files
Git
Chapter Summary
Chapter 11 Create Quiz Web App with Python Django
React, Flask, Ruby on Rails, etc.
How to Create a Quiz List App in Python Django
Purpose
Project Prerequisites
Virtual Environment
Changing in Our Models
Making a Migration
Migrating to the Database
Registering to the Admin
Creating Superuser and Viewing in the Admin Panel
Making and Changing the Templates
Base​.ht​ml
Login​.ht​ml
Login Page
Register Page
Home Page
Result Page
url​.​py
url​.​py
form​.​py
view​.​py
app​.​py
What Is the Purpose of This Project?
Chapter 12 Project To-Do List
React, Flask, Ruby on Rails, etc.
How to Create a To-Do List App in Python Django
Creating Superuser and Viewing in the Admin Panel
Making a Migration
Migrating to the Database
Edit Page
After Edit Page
Login Page
Register Page
Show Details Page
Views​.​py
urls​.​py
model​.​py
forms​.​py
Apps​.​py
admin​.​py
In admin​.​py
Chapter 13 Comparative Study between Django, Flask, Node.Js, and Spring Boot
Types of Python Framework
What Is Flask?
Django VS Node​.​js
What Is Node​.j​s?
Django vs. Spring Boot
What Is Spring Boot?
Chapter Summary
Appraisal
Bibliography
Index