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.
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.
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!
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.
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.
Senior Engineering Manager at Bosch
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.
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.
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.
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.
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.
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.
Chapter 6, Sharing Content on Your Website
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.
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.
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.
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.
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.
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.
Chapter 13, Creating a Content Management System
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.
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.
Chapter 16, Building a Chat Server
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.
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.