Django 4 By Example book

Antonio Melé

What readers say

This book stems from the experience acquired by Antonio during several years spent in the field developing real-world applications. If you've ever asked yourself "how something should be done", you will most likely find a solid answer here.

Giuseppe Ciotta
VP of Engineering at Belvo

This book is the perfect material to advance your Django learning. It constitutes a reference material, showing you different examples of how to solve problems that will take you to the next level, allowing you to tackle more complex developments than you ever imagined.

Tomás Garzón
Python Engineer at Revolut

The examples in the book are just awesome! This is a hands-on guide on how to do real world applications. If you are new to Django, I'd recommend you to read this book and build the example applications. You'll be doing great stuff in no time!

Jaakko Tulkki
Lead Software Engineer at Barclays

The topics covered on this book are based on real work situations, that will help you get the job done and learn in the process! Extensive analysis of each problem that takes you from point A to point B. A must have if you're looking into doing Django based projects professionally.

Panos Laganakos
Technical Lead at AireHealth

The topics covered in the book are among the most demanded by the web industry today. This book is the perfect extension to the official Django docs, and is as good a reading experience for perfectionists with deadlines as for those looking to build a professional website.

Daniela Rus
Senior Engineering Manager at Infineon Technologies

Learn Django building practical, real-world applications

Django 4 by Example will guide you through the entire process of developing professional web applications with Django. The book not only covers the most relevant aspects of the framework, but it will also teach you how to integrate other popular technologies into your Django projects.

The book will walk you through the creation of four real-world applications, solving common problems, and implementing best practices, using a step-by-step approach that is easy to follow.

After reading this book, you will have a good understanding of how Django works and how to build practical, advanced web applications.

4th

edition
764

pages
4

professional Django projects

Build four different real-world applications


Blog application

Image sharing website

E-commerce application

E-learning platform

Book chapters

1

Chapter 1, Building a Blog Application

This chapter will introduce you to the framework through a blog application. You will create the basic blog models, views, templates, and URLs to display blog posts. You will learn how to build QuerySets with the Django object-relational mapper (ORM), and you will configure the Django administration site.

2

Chapter 2, Enhancing Your Blog with Advanced Features

This chapter will teach you how to will teach you how to add pagination to your blog, and how to implement Django class-based views. You will learn to send emails with Django, and handle forms and model forms. You will also implement a comment system for blog posts.

3

Chapter 3, Extending Your Blog Application

This chapter explores how to integrate third-party applications. This chapter will guide you through the process of creating a tagging system, and you will learn how to build complex QuerySets to recommed similar posts. The chapter will teach you how to create custom template tags and filters. You will also learn how to use the sitemap framework and create an RSS feed for your posts. You will complete your blog application by building a search engine using PostgreSQL's full-text search capabilities.

4

Chapter 4, Building a Social Website

This chapter how to build a social website. You will learn how to use the Django authentication framework, and you will extend the user model with a custom profile model. The chapter will teach you how to use the messages framework and you will build a custom authentication backend.

5

Chapter 5, Implementing Social Authentication

This chapter covers implementing social authentication with Google, Facebook, and Twitter using OAuth 2 with Python Social Auth. You will learn how to use Django Extensions to run the development server through HTTPS and customize the social authentication pipeline to automate the user profile creation.

6

Chapter 6, Sharing Content on Your Website

will teach you how to transform your social application into an image bookmarking website. You will define many-to-many relationships for models, and you will create a JavaScript bookmarklet that integrates into your project. The chapter will show you how to generate image thumbnails. You will also learn how to implement asynchronous HTTP requests using JavaScript and Django and you will implement infinite scroll pagination.

7

Chapter 7, Tracking User Actions

This chapter will show you how to build a follower system for users. You will com- plete your image bookmarking website by creating a user activity stream application. You will learn how to create generic relations between models and optimize QuerySets. You will work with signals and implement denormalization. You will use Django Debug Toolbar to obtain relevant debug information. Finally, you will integrate Redis into your project to count image views and you will create a ranking of the most viewed images with Redis.

8

Chapter 8, Building an Online Shop

This chapter explores how to create an online shop. You will build models for a product catalog, and you will create a shopping cart using Django sessions. You will build a context processor for the shopping cart and will learn how to manage customer orders. The chapter will teach you how to send asynchronous notifications using Celery and RabbitMQ. You will also learn to monitor Celery using Flower.

9

Chapter 9, Managing Payments and Orders

This chapter explains how to integrate a payment gateway into your shop. You will integrate Stripe Checkout and receive asynchronous payment notifications in your application. You will implement custom views in the administration site and you will also customize the administration site to export orders to CSV files. You will also learn how to generate PDF invoices dynamically.

10

Chapter 10, Extending Your Shop

This chapter will teach you how to create a coupon system to apply discounts to the shopping cart. You will update the Stripe Checkout integration to implement coupon discounts and you will apply coupons to orders. You will use Redis to store products that are usually bought together, and use this information to build a product recommendation engine.

11

Chapter 11, Adding Internationalization to Your Shop

The chapter will show you how to add internationalization to your project. You will learn how to generate and manage translation files and translate strings in Python code and Django templates. You will use Rosetta to manage translations and implement per-language URLs. You will learn how to translate model fields using django-parler and how to use translations with the ORM. Finally, you will create a localized form field using django-localflavor.

12

Chapter 12, Building an E-Learning Platform

This chapter will guide you through creating an e-learning platform. You will add fixtures to your project, and create initial models for the content management system. You will use model inheritance to create data models for polymorphic content. You will learn how to create custom model fields by building a field to order objects. You will also implement authentication views for the CMS.

13

Chapter 13, Creating a Content Management System

This chapter will teach you how to create a CMS using class-based views and mixins. You will use the Django groups and permissions system to restrict access to views and implement formsets to edit the content of courses. You will also create a drag-and-drop functionality to reorder course modules and their content using JavaScript and Django.

14

Chapter 14, Rendering and Caching Content

This chapter will show you how to implement the public views for the course catalog. You will create a student registration system and manage student enrollment on courses. You will create the functionality to render different types of content for the course modules. You will learn how to cache content using the Django cache framework and configure the Memcached and Redis cache backends for your project. Finally, you will learn how to monitor Redis using the administration site.

15

Chapter 15, Building an API

This chapter explores building a RESTful API for your project using Django REST framework. You will learn how to create serializers for your models and create custom API views. You will handle API authentication and implement permissions for API views. You will learn how to build API viewsets and routers. The chapter will also teach you how to consume your API using the Requests library.

16

Chapter 16, Building a Chat Server

This chapter explains how to use Django Channels to create a real-time chat server for students. You will learn how to implement functionalities that rely on asynchronous com- munication through WebSockets. You will create a WebSocket consumer with Python and implement a WebSocket client with JavaScript. You will use Redis to set up a channel layer and you will learn how to make your WebSocket consumer fully asynchronous.

17

Chapter 17, Going Live

This chapter will show you how to create settings for multiple environments and how to set up a production environment using PostgreSQL, Redis, uWSGI, NGINX, and Daphne with Docker Compose. You will learn how to serve your project securely through HTTPS and use the Django sys- tem check framework. The chapter will also teach you how to build a custom middleware and create custom management commands.

Use Django with multiple technologies

Previous editions in other languages


Django 3项目实例精解
ISBN: 9787302581840

Aprenda Django 3 com exemplos
ISBN: 9786586057232

Django 3. Praktyczne tworzenie aplikacji sieciowych. Wydanie III
ISBN: 9788328372504

Django 3 kroz primere, prevod III izdanja
ISBN: 9788673105529
Antonio Melé

About Antonio Melé

Antonio Melé is the Chief Technology Officer at Nucoro, the fintech platform to build and scale digital investment products. Antonio has been developing Django projects since 2006 for clients across several industries. In 2009, he founded Zenx IT, a development company specializing in building digital products. Antonio holds an M.Sc. in computer science from ICAI - Universidad Pontificia Comillas. His father inspired his passion for computers and programming.