<p><b>Learn how to create your own websites simply, safely, and quickly with Django by tackling practical activities based on realistic case studies</b></p><h4>Key Features</h4><ul><li>Understand Django functionality and the Model-View-Template (MVT) paradigm</li><li>Create and iteratively build a b
Web Development with Django: Learn to build modern web applications with a Python-based framework
β Scribed by Ben Shaw, Saurabh Badhwar, Andrew Bird, Bharath Chandra K S, Chris Guest
- Publisher
- Packt Publishing
- Year
- 2021
- Tongue
- English
- Leaves
- 826
- Category
- Library
No coin nor oath required. For personal study only.
β¦ Synopsis
Learn how to create your own websites simply, safely, and quickly with Django by tackling practical activities based on realistic case studies
Key Features
- Understand Django functionality and the Model-View-Template (MVT) paradigm
- Create and iteratively build a book review website, adding features as you build your knowledge
- Explore advanced concepts such as REST API implementation and third-party module integration
Book Description
Do you want to develop reliable and secure applications which stand out from the crowd, rather than spending hours on boilerplate code? Then the Django framework is where you should begin. Often referred to as a 'batteries included' web development framework, Django comes with all the core features needed to build a standalone application.
Web Development with Django takes this philosophy and equips you with the knowledge and confidence to build real-world applications using Python.
Starting with the essential concepts of Django, you'll cover its major features by building a website called Bookr β a repository for book reviews. This end-to-end case study is split into a series of bitesize projects that are presented as exercises and activities, allowing you to challenge yourself in an enjoyable and attainable way.
As you progress, you'll learn various practical skills, including how to serve static files to add CSS, JavaScript, and images to your application, how to implement forms to accept user input, and how to manage sessions to ensure a reliable user experience. Throughout this book, you'll cover key daily tasks that are part of the development cycle of a real-world web application.
By the end of this book, you'll have the skills and confidence to creatively tackle your own ambitious projects with Django.
What you will learn
- Create a new application and add models to describe your data
- Use views and templates to control behavior and appearance
- Implement access control through authentication and permissions
- Develop practical web forms to add features such as file uploads
- Develop a RESTful API and JavaScript code that communicates with it
- Connect to a database such as PostgreSQL
Who this book is for
Web Development with Django is designed for programmers who want to gain web development skills with the Django framework. To fully understand the concepts explained in this book, you must have basic knowledge of Python programming, as well as familiarity with JavaScript, HTML, and CSS.
Table of Contents
- Introduction to Django
- Models and Migrations
- URL Mapping, Views, and Templates
- Introduction to Django Admin
- Serving Static Files
- Forms
- Advanced Form Validation and Model Forms
- Media Serving and File Uploads
- Sessions and Authentication
- Advanced Django Admin and Customizations
- Advanced Templating and Class Based Views
- Building a REST API
- Generating CSV, PDF, and Other Binary Files
- Testing
- Django Third-Party Libraries
- Using a Frontend JavaScript Library with Django
β¦ Table of Contents
Cover
FM
Copyright
Table of Contents
Preface
Chapter 1: Introduction to Django
Introduction
Scaffolding a Django Project and App
Exercise 1.01: Creating a Project and App, and Starting the Dev Server
Model View Template
Models
Views
Templates
MVT in Practice
Introduction to HTTP
Processing a Request
Django Project
The myproject Directory
Django Development Server
Django Apps
PyCharm Setup
Exercise 1.02: Project Setup in PyCharm
View Details
URL Mapping Detail
Exercise 1.03: Writing a View and Mapping a URL to It
GET, POST, and QueryDict Objects
Exercise 1.04: Exploring GET Values and QueryDict
Exploring Django Settings
Using Settings in Your Code
Finding HTML Templates in App Directories
Exercise 1.05: Creating a Templates Directory and a Base Template
Rendering a Template with the render Function
Exercise 1.06: Rendering a Template in a View
Rendering Variables in Templates
Exercise 1.07: Using Variables in Templates
Debugging and Dealing with Errors
Exceptions
Exercise 1.08: Generating and Viewing Exceptions
Debugging
Exercise 1.09: Debugging Your Code
Activity 1.01: Creating a Site Welcome Screen
Activity 1.02: Book Search Scaffold
Summary
Chapter 2: Models and Migrations
Introduction
Databases
Relational Databases
Non-Relational Databases
Database Operations Using SQL
Data Types in Relational databases
Exercise 2.01: Creating a Book Database
SQL CRUD Operations
SQL Create Operations
SQL Read Operations
SQL Update Operations
SQL Delete Operations
Django ORM
Database Configuration and Creating Django Applications
Django Apps
Django Migration
Creating Django Models and Migrations
Field Types
Field Options
Primary Keys
Relationships
Many to One
Many to Many
One-to-One Relationships
Adding the Review Model
Model Methods
Migrating the Reviews App
Djangoβs Database CRUD Operations
Exercise 2.02: Creating an Entry in the Bookr Database
Exercise 2.03: Using the create() Method to Create an Entry
Creating an Object with a Foreign Key
Exercise 2.04: Creating Records for a Many-to-One Relationship
Exercise 2.05: Creating Records with Many-to-Many Relationships
Exercise 2.06: A Many-to-Many Relationship Using the add() Method
Using create() and set() Methods for Many-to-Many Relationships
Read Operations
Exercise 2.07: Using the get() Method to Retrieve an Object
Returning an Object Using the get() Method
Exercise 2.08: Using the all() Method to Retrieve a Set of Objects
Retrieving Objects by Filtering
Exercise 2.09: Using the filter() Method to Retrieve Objects
Filtering by Field Lookups
Using Pattern Matching for Filtering Operations
Retrieving Objects by Excluding
Retrieving Objects Using the order_by() Method
Querying Across Relationships
Querying Using Foreign Keys
Querying Using Model Name
Querying Across Foreign Key Relationships Using the Object Instance
Exercise 2.10: Querying Across a Many-to-Many Relationship Using Field Lookup
Exercise 2.11: A Many-to-Many Query Using Objects
Exercise 2.12: A Many-to-Many Query Using the set() Method
Exercise 2.13: Using the update() Method
Exercise 2.14: Using the delete() Method
Activity 2.01: Create Models for a Project Management Application
Populating the Bookr Projectβs Database
Summary
Chapter 3: URL Mapping, Views, and Templates
Introduction
Function-Based Views
Class-Based Views
URL Configuration
Exercise 3.01: Implementing a Simple Function-Based View
Templates
Exercise 3.02: Using Templates to Display a Greeting Message
Django Template Language
Template Variables
Template Tags
Comments
Filters
Exercise 3.03: Displaying a List of Books and Reviews
Template Inheritance
Template Styling with Bootstrap
Exercise 3.04: Adding Template Inheritance and a Bootstrap Navigation Bar
Activity 3.01: Implement the Book Details View
Summary
Chapter 4: Introduction to Django Admin
Introduction
Creating a Superuser Account
Exercise 4.01: Creating a Superuser Account
CRUD Operations Using the Django Admin App
Create
Retrieve
Update
Delete
Users and Groups
Exercise 4.02: Adding and Modifying Users and Groups through the Admin app
Registering the Reviews Model
Change Lists
The Publisher Change Page
The Book Change Page
Exercise 4.03: Foreign Keys and Deletion Behavior in the Admin App
Customizing the Admin Interface
Site-Wide Django Admin Customizations
Examining the AdminSite object from the Python Shell
Subclassing AdminSite
Activity 4.01: Customizing the SiteAdmin
Customizing the ModelAdmin Classes
The List Display Fields
The Filter
Exercise 4.04: Adding a Date list_filter and date_hierarchy
The Search Bar
Excluding and Grouping Fields
Activity 4.02: Customizing the Model Admins
Summary
Chapter 5: Serving Static Files
Introduction
Static File Serving
Introduction to Static File Finders
Static File Finders: Use During a Request
AppDirectoriesFinder
Static File Namespacing
Exercise 5.01: Serving a File from an App Directory
Generating Static URLs with the static Template Tag
Exercise 5.02: Using the static Template Tag
FileSystemFinder
Exercise 5.03: Serving from a Project static Directory
Static File Finders: Use During collectstatic
Exercise 5.04: Collecting Static Files for Production
STATICFILES_DIRS Prefixed Mode
The findstatic Command
Exercise 5.05: Finding Files Using findstatic
Serving the Latest Files (for Cache Invalidation)
Exercise 5.06: Exploring the ManifestFilesStorage Storage Engine
Custom Storage Engines
Activity 5.01: Adding a reviews Logo
Activity 5.02: CSS Enhancements
Activity 5.03: Adding a Global Logo
Summary
Chapter 6: Forms
Introduction
What Is a Form?
The
π SIMILAR VOLUMES
Do you want to develop reliable and secure applications that stand out from the crowd without spending hours on boilerplate code? You've made the right choice trusting the Django framework, and this book will tell you why. Often referred to as a βbatteries includedβ web development framework, Django
Work through realistic case studies to create your own websites easily, securely, and quickly Key Features β’ Understand Django functionality and the Model-View-Template (MVT) paradigm β’ Create and iteratively build a book review website, adding features as you build your knowledge β’ Explore ad
<span>Django is exciting if you are interested in building websites. Django is a framework for making websites. It saves you a lot of time and makes building websites easier and more fun. Django makes it easy to build and maintain high-quality web applications.<br>Web development is a creative journ
Python is one of the most versatile high-level programming languages ever developed. Rather than having to jump into strict syntax rules, Python reads like English and is simple to understand for someone new to programming. This allows you to obtain a basic knowledge of coding practices without havi
It's an okay book, they help you work through a project, but I feel the following book is better if you are just starting off with Django (I bought it today because I feel it is far better):The Definitive Guide to Django: Web Development Done Right, Second EditionI plan on returning to Learning Webs