Python Web Frameworks
From models, views and templates to forms, authentication, programming interfaces, asynchronous code and deployment in Django, Flask and FastAPI, Python web frameworks as told through the free samples of the Leanpub books about them.
Created from the free samples of 7 Leanpub books and the descriptions and tables of contents of 21 more, with every source cited.
A Python web framework is a library that takes over the routine parts of a web application, matching addresses to code, reading requests, talking to a database and producing pages or data in reply, so that a developer writes only what is particular to the application. Three account for almost all the books here. Django is the large one, whose philosophy one introduction calls batteries included, meaning that it arrives with most of what an application needs already built in.[3] Flask is the small one, a microframework that by the account of a long book about it starts with the minimum necessary to function.[15] FastAPI is the newest, made for programming interfaces, and its ideas have been carried back into Django by a tool called Django Ninja.[4]
Django has by far the most books, and the most widely sold of them is a university tutorial, now in several editions, whose premise is that a framework saves trouble and time only for those who know how to use it, and that the learning curve is often steep.[1] Most of the others are also books of projects: an application is specified in the first chapter and built, feature by feature, in the rest.
This article covers where to begin, the history, designing a Django application, what Django provides, Flask, FastAPI and the frameworks for programming interfaces, front ends and real-time features, and the generation of applications by language models. Its sources are the free samples of the Leanpub books listed at the end, with the descriptions and tables of contents of the books whose samples were not available, and every claim that rests on a source is cited to it.
Where to start
All of these frameworks assume the language. A reader without Python can learn the essentials from Beginner's Python Cheat Sheets (2021), a set of printable summaries of lists, dictionaries, strings and the other core ideas,[7] or begin with Python Django Flask (2021), a short book that teaches the basics of the language before building a small application in each of two frameworks.[13]
For Django the usual first book is the tutorial that builds a directory of links: Tango With Django 4 (2023) is the current edition, and Tango With Django 2 (2020) and How to Tango with Django 1.9/1.10/1.11 (2018) remain listed for older versions of the framework.[8][2][1] Mastering Django 4: Projects for Beginners (2024) is a beginner's course in progressively larger projects,[3] and Django 6.1 with Python 3.14 teaches the current release to newcomers and to experienced users catching up.[9]
For Flask, Python Flask is a compact run of small examples, each followed by its test,[17] Web Programming With Python and Flask: A Comprehensive Guide is a structured textbook,[16] and Flask and Python Web From Zero to Advanced: REST APIs, Admin Panel and Real-Time Chat is the long treatment.[15] For FastAPI there are Python FastAPI, in the same form of examples with tests,[19] and Build Real Backend Apps with Python & FastAPI (2025), which grows one application through the whole book.[20] Django Ninja made Simple introduces interfaces in Django to readers new to both.[4]
Developers who already work in Django can go to Async Patterns in Django (2024) for asynchronous techniques,[25] to The Definitive Guide to Hotwire and Django (2.0.0) (2023) for interactive pages without a JavaScript framework,[24] or to Practical Pydantic (2025) for the validation of data.[5]
History
Django was written in 2003 at a newspaper, whose developers needed to build database-backed sites to journalistic deadlines, and was released as open source in 2005. Flask appeared in 2010 as a deliberately small alternative that left the choice of database layer, forms and almost everything else to the developer. FastAPI, released in 2018, was built on two additions to the language itself, annotations of type and asynchronous functions, and used the first to check incoming data and to document an interface automatically. Django in turn has added asynchronous support by stages since 2019.
The shelf records these changes in its editions. The tutorial that builds a directory of links was written for one version of Django, rewritten for Django 2 and the third major version of the language, and issued again for Django 4,[1][2][8] and Django 6.1 with Python 3.14 exists because, as its description says, two recent releases of the framework and one of the language brought many changes.[9] Django Ninja made Simple sets the older and newer generations side by side in a table: the new tool is built on the asynchronous server interface and the established package on the synchronous one, and it validates data and generates documentation where the other needs configuration.[4] Prompt Genius: Generate Python Web Applications using AI (2023) dates from the arrival of language models that write code, and opens with the statement that software development has completely changed.[6]
Designing a Django application
How to Tango with Django 1.9/1.10/1.11 was written for students, to complement the official tutorials by putting in one place what its authors had seen clever students lose hours over: usually, they say, a key piece of information that was not provided or not made clear. Its instruction to the reader is blunt. The book is not designed to be read; reading is not doing; the code should be typed in and not pasted, thought about, and checked against the documentation when it is not understood. It also answers a complaint the authors heard from many students, that a framework takes control away from the programmer. A framework does require its user to adopt a particular design pattern and to fill in certain pieces in certain places, and the book supplies a set of workflows, one for each recurring task, so that the application can be built in a disciplined way and the sense of control recovered.[1]
Before any code the book sets a design brief and asks the reader to draw four things: a diagram of the system's architecture, wireframes of the main pages, a list of the addresses users will visit, and a diagram of the data. The architecture of most web applications, it explains, has three tiers, a browser as client, the Django application in the middle and a database behind it, with a variation in this case because the application also calls an external search service; the book concentrates on the middle tier while having to deal with all the others. Wireframes can be anything from a sketch to an exact mock-up. The addresses are written as patterns, one for the index, one for an about page and one for each category by name, and the data comes down to two entities, a category and a page, where one category has many pages.[1] The later edition puts the exercises as questions, what the architecture will be, what the interface will look like, what the addresses will be and what data must be stored, and asks how the reader would describe formally what is to be built so that someone else could understand it.[2]
The tasks that follow are the usual sequence for the framework: setting up the environment, creating a project and an application within it, serving static and uploaded files, working with the pattern of model, view and template, defining models and using the mapping between objects and tables, building forms from the models, authenticating users, calling external services, styling pages, and working with cookies and sessions.[2] The current edition, the fifth of a book first issued in 2013, adds class-based views and testing, covers the whole path from design to deployment on a hosting service, and describes its workflows as a way into the mindset of the framework that also explains the reasons behind the practices it recommends.[8]
What Django provides
Mastering Django 4: Projects for Beginners describes Django as a free, open-source framework used on some of the largest sites on the web and still flexible enough for a start-up or a personal project, and lists its parts. Models are Python classes that the framework translates into database tables, so that data is read and written in Python and not in SQL. An administrative interface is generated automatically from the models. A dispatcher maps addresses to views; a template engine keeps the layout of pages apart from the logic; there are built-in tools for user accounts and permissions, protections against the common attacks on web applications, components called middleware that process every request and response, and a framework for forms and their validation. Several databases are supported, and a large community supplies reusable packages. The design pattern is the familiar one of model, view and controller, which Django's own terminology renames model, view and template.[3]
The same book proceeds by projects, from a page that prints a greeting to a site of job listings with a custom user model, email, permissions and authorisation, uses the packaging tool it describes as officially recommended, and puts strong emphasis on testing. It calls itself a living document, revised as the framework and the language are.[3] Django 6.1 with Python 3.14 is built round six projects of rising difficulty and a final case study, each introducing one new technology and returning to those already met, on the argument that the changes in recent releases sink in only inside projects that make sense. It begins with a task manager, with models, migrations, the administrative interface, forms, templates and first tests, goes on to a blog that uses the special features of one database, a shop with a live basket, a knowledge base that answers questions by semantic search and a project on background jobs, and finishes with a system for managing documents running on a server.[9] Django Unleashed: Building High-Performance Web Applications With Python goes from project structure, the mapping layer, views, templates and forms to interfaces and production.[12] Django 6: Create your online store step by step and Django 6: Create your online store step by step, by one author, build an online shop with a blog, filters, pagination and two payment gateways, with the aim that the reader should understand how a professional application is organised.[11][10] Python project pro VOL-1 offers eight web applications to build for a portfolio.[14]
Flask
Flask gives the developer routing, requests and templates and leaves the rest to extensions, which is why the books about it are largely tours of those extensions. Flask and Python Web From Zero to Advanced: REST APIs, Admin Panel and Real-Time Chat has twenty-seven chapters, and after installation and an introduction to the language adds in turn a template engine, a database mapper with migrations, forms, logins, interfaces, tests, translation, roles, deployment, chat over sockets, a task queue, a security extension and a billing system.[15] Web Programming With Python and Flask: A Comprehensive Guide moves from the basics of the web and a first application through routing, templates, forms, the database and authentication.[16] Python Flask covers routing, the handling of requests, templates, sessions, error pages, interfaces that return data, logins and deployment in short examples with exercises.[17]
Web Development with Python. Building backend services and dynamic websites with a framework like Flask, the third volume of a series, addresses the reader who has mastered the syntax and still writes scripts that run only on one machine, and goes from the protocol of the web and the model of client and server to a framework, a database layer and interfaces.[18] Two adjacent books use Flask on the way to something else: Python project pro VOL-6, a volume of projects on the gap between writing code and delivering it, packages a Flask application in a container and deploys it through an automated pipeline,[27] and How to build a chat application with LLMs locally and Jan IA or LM Studio and connect to Python puts a small Flask application in front of language models running on the reader's own computer, so that a chat assistant works without sending data anywhere else.[28]
FastAPI and the interface frameworks
A programming interface returns data, usually as JSON, to a mobile application or to JavaScript in a browser, and the newer frameworks are designed for that job. Python FastAPI works through parameters in the address and the query, request bodies, errors, headers, static files and applications mounted inside one another.[19] Build Real Backend Apps with Python & FastAPI objects that most tutorials teach fragments and never the whole, and builds a single back end that handles data, validates input, uses a database, serves a front end and authenticates users, treating errors, in its description's words, as tools for learning.[20]
Django Ninja made Simple explains Django Ninja as a way of building interfaces in Django with less code. The tool takes incoming data, checks automatically that it is valid and complete, passes it to the developer's function, returns the result as JSON, and builds an interactive page of documentation from which every endpoint can be tried in the browser; the book's first example is a function of two lines under a one-line decoration. A note for beginners says that the tool does not replace Django: models, the mapping layer and settings are used as before. The chapters go on to routers and schemas, file uploads, the injection of dependencies, tokens and roles, pagination, background tasks and sockets, and end with an interface for a hospital, deployment, testing and interview questions.[4]
The checking in both tools is done by one validation library, the subject of Practical Pydantic. Annotations of type in Python, the book observes, do not enforce anything when a program runs; the library combines them with validation at run time and so closes the gap between what code says it does and what it does in production. The author's own reason for writing is the bugs that bad data caused: payloads that did not match the expected shape, configuration files with typing errors, untidy input that broke whole workflows. With the library the annotations became, in the author's phrase, guards at the gate. The book is for developers of interfaces, for data engineers who must validate and normalise untidy data before it is used, and for anyone managing configuration across environments; it asks only a working knowledge of the language, ends most chapters with exercises, can be read straight through or entered at the chapters on interfaces, and has a part on the alternatives.[5]
Front ends and real-time features
A Django application traditionally renders its own pages, and several books deal with what happens when a richer front end is wanted. Three by one author pair a content management system built on Django with a JavaScript front end in three different architectures: Build SPA with React and Wagtail (3.0.0) (2023) as a single-page application fed by an interface,[21] Build Blog with React (SSR) and Wagtail (2021) with components rendered on the server inside Django's templates, for performance and for search engines,[22] and The Definitive Guide to Next.js and Wagtail (2.0.0) (2022) with pages built in advance and served from a content delivery network, an arrangement whose name the description spells out as JavaScript, interfaces and markup.[23] The same author's The Definitive Guide to Hotwire and Django (2.0.0) takes the opposite course, sending fragments of HTML from the server to get the behaviour of a single-page application without such a framework or a data interface, and builds a task manager with editing in place, dialogs, search and live updates.[24]
Async Patterns in Django collects the asynchronous patterns: task queues, sockets, subscriptions, events sent from the server, streamed responses and long polling, each built into one sample application.[25]
Generated applications and interviews
Prompt Genius: Generate Python Web Applications using AI generates a Django application by a sequence of prompts to a language model, one for each stage from the setting up of a project to authentication and reports. The method, it says, follows established practice in which an application is designed largely by stating its requirements in natural language, the data it manages and what users may do with it. What changes is the need for precision: traditional development leaves room to elaborate requirements at each iteration, whereas a prompt must carry everything relevant, because any detail not given will be decided by the model, sometimes acceptably and sometimes not. The book calls prompt engineering a grand name for the simple skill of putting one's thoughts into clear text, and claims that the coding part of a project shrinks from months to days. It quotes the maxim that a problem well stated is half solved, and remarks that the other half is now dealt with faster than before.[6]
The Python and Django Interview Compendium is a reference of more than two hundred interview questions in fifteen chapters, divided about evenly between the language and Django. Each answer, according to the description, goes past the definition to the mechanism behind it and the trade-off it carries, so that a reader can reason about a question not seen before; the Django chapters run from project structure, models and migrations through views, forms, interfaces and security to caching, performance and the diagnosis of faults in production.[26]
Sources
Every source is a Leanpub book. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.
- 1.How to Tango with Django 1.9/1.10/1.11, Leif Azzopardi, David Maxwell: A beginners guide to Python/Django Free sample: the overview, the design brief and the opening of the setup chapter. 2018. Free sample: PDF · EPUB
- 2.Tango With Django 2, Leif Azzopardi and David Maxwell, David Maxwell: A beginner's guide to web development with Django 2. Free sample: the overview and the design brief, as revised for a later version of the framework. 2020. Free sample: PDF · EPUB
- 3.Mastering Django 4: Projects for Beginners, Aditya Dhandi: Beginner's Journey to Django 4 Mastery: Projects and Beyond Free sample: the introduction, on the book's approach and on what Django is. 2024. Free sample: PDF
- 4.Django Ninja made Simple, SYLVESTER BENJAMIN: A Beginner-Friendly Guide to Building Modern APIs with Python Django Ninja (2nd Edition), Featuring Three Practical Projects & Step-by-Step Deployment Guide Free sample: the contents and the first chapter, on what Django Ninja is. 2026. Free sample: PDF
- 5.Practical Pydantic, Nuno Bispo: The Missing Guide to Data Validation in Python Free sample: the preface, on why the book was written and for whom. 2025. Free sample: PDF · EPUB
- 6.Prompt Genius: Generate Python Web Applications using AI, Darren Broemmer Free sample: the opening chapter, on the method. 2023. Free sample: PDF · EPUB
- 7.Beginner's Python Cheat Sheets, Eric Matthes Free sample: the first sheets, on variables, lists and dictionaries. 2021. Free sample: PDF
- 8.Tango With Django 4, Leif Azzopardi, David Maxwell: A beginner's guide to web development with Django 4 No sample: from the description and table of contents. 2023.
- 9.Django 6.1 with Python 3.14, Franky Bonanno: From your first project to production: complete web applications with PostgreSQL, semantic search with pgvector, and dynamic interfaces with HTMX The free sample stops before the framework is reached: from the description. 2026. Free sample: PDF · EPUB
- 10.Django 6: Create your online store step by step, Andrés Cruz Yoris: Build a modern and scalable application with a blog, ecommerce, multilingual support, and Stripe or PayPal payment gateways. The free sample does not match the listing: from the description only. 2026. Free sample: PDF
- 11.Django 6: Create your online store step by step, Andrés Cruz Yoris: Build a modern and scalable application with a blog, ecommerce, multilingual support, and Stripe or PayPal payment gateways. No sample: from the description. 2026.
- 12.Django Unleashed: Building High-Performance Web Applications With Python, Anshuman Mishra No sample: from the description and table of contents. 2026.
- 13.Python Django Flask, Joseph Thachil George: Python Django The free sample is contents only: from that and the description. 2021. Free sample: PDF
- 14.Python project pro VOL-1, Anshuman Mishra: 50 industry-ready projects for aspiring software professionals No sample: from the description and table of contents. 2026.
- 15.Flask and Python Web From Zero to Advanced: REST APIs, Admin Panel and Real-Time Chat, Andrés Cruz Yoris: Build professional applications with Flask, SQLAlchemy, Jinja2, Bootstrap, Vue, Flask-Login, JWT, Socket.IO, billing, user roles, and automated testing. No sample: from the description. 2026.
- 16.Web Programming With Python and Flask: A Comprehensive Guide, Anshuman Mishra No sample: from the description and table of contents. 2026.
- 17.
- 18.Web Development with Python. Building backend services and dynamic websites with a framework like Flask, Edgar Milvus No sample: from the description. 2026.
- 19.
- 20.Build Real Backend Apps with Python & FastAPI, Roberto Stepic No sample: from the description. 2025.
- 21.Build SPA with React and Wagtail (3.0.0), MichaelYin No sample: from the description and table of contents. 2023.
- 22.Build Blog with React (SSR) and Wagtail, MichaelYin No sample: from the description and table of contents. 2021.
- 23.The Definitive Guide to Next.js and Wagtail (2.0.0), MichaelYin No sample: from the description and table of contents. 2022.
- 24.The Definitive Guide to Hotwire and Django (2.0.0), MichaelYin No sample: from the description and table of contents. 2023.
- 25.Async Patterns in Django, Paul Bailey: A comprehensive guide to asynchronous programming and protocols in Django No sample: from the description and table of contents. 2024.
- 26.The Python and Django Interview Compendium, Yohan J. Rodríguez: Interview Questions and Answers for Python and Django Developers The free sample covers the language half only: from the description and table of contents. 2026. Free sample: PDF
- 27.Python project pro VOL-6, Anshuman Mishra: 50 industry-ready projects for aspiring software professionals No sample: from the description and table of contents. 2026.
- 28.How to build a chat application with LLMs locally and Jan IA or LM Studio and connect to Python, Andrés Cruz Yoris: LLMs on your PC: Create your own ChatGTP-style app with Jan AI and Python Flask No sample: from the description and table of contents. 2026.
Further reading
Other books in the library on neighbouring ground, not cited above.
- Python Programming from Beginner to Paid Professional Part 1, Bolakale Aremu: Learn Python for Automation & IT with Video Tutorials The first part of a three-part course in the Python language. 2026. Free sample: PDF · EPUB
- Python Rocket Science, Karan Singh: Proven fast-track learning that has been used internationally for over five years in software developer bootcamps. A compact course in the Python language, as used in coding bootcamps. 2022. Free sample: PDF
- Python For Busy People, Derrick Cassidy: Designed for Busy People with Deadlines A short walk through the fundamentals of Python. 2023.
- The Python Interview Handbook 2023, Nezir Zahirovic: Your Ultimate Guide to Crack Any Python Interview with 500 Q & A More than five hundred interview questions and answers on Python and the work around it. 2023.
- Build an AI Quiz Generator with Python, Mike Gold: Create quizzes, validate AI output, export printable worksheets, and build a Django web app. A project that builds a quiz generator in Python, ending with a web version. 2026.