Book Review: Django 5 by Example
Field | Details |
---|---|
Title | Django 5 By Example |
Author | Antonio Melé |
Published | 2024 |
ISBN-13 | 978-1805125457 |
Overview
Why I chose it
I was looking to increase my breadth of knowledge in Django, and go beyond the APIs that I had already built in the past. Most courses didn’t have the depth or breadth I was looking for.
This book takes you through four example projects that are well-structured and non-trivial:
- A blog with standard Django functionality
- A social media site for bookmarking and sharing images
- An online shop with cart functionality, order management, Stripe integration, and webhooks
- A content management system with caching, APIs, websockets, and Docker for deployment
Who it’s for
In my opinion, this is not a beginner book. It does target the core functionality of Django to begin with, including the app structure, admin site, models, views, forms, and templates. That said, it would be helpful to have a practical understanding of these elements beforehand, particularly from the official Django tutorial 1 and possibly the Django Girls tutorial 2.
This book would be perfect for anyone who has followed at least one tutorial and is looking to close gaps in their knowledge, or someone who uses Django as a REST API but hasn’t yet touched Django’s routing, views, forms, or templates.
Reflection
Django 5 By Example offers an impressive range of topics for its size, including four solid projects. Although the last page of substance is around page 760, I managed to complete the book in about six weeks, at a pace of around 20 pages per day.
I had already used Django with Django REST Framework to serve JSON, and built a couple of small applications using MVT architecture. I definitely benefited from the repetition by creating several applications in such a short space of time. I now appreciate the value of views, forms, and templates much more than I did before.
You will get the opportunity to use a wide variety of features, such as forms (including ModelForm
for simple cases), and function- and class-based views. You will be comfortable with routing, configuring settings.py
, and integrating third-party services for authentication and payments.
One of the great parts about this book is that the code actually works. There is very little ambiguity as the book is explicit on what to do next. The projects are end-to-end and self-contained, so there are no loose ends (although you are free to add more features if you wish).
Strengths
- Breadth of coverage: the last example takes you from nothing to a fully-fledged and deployed application, using a wide variety of features
- Includes Django 5: the book calls out recent additions to the framework and has clearly been updated with this in mind
- Repetition: a similar approach is used to build each project, allowing you to become familiar with Django’s project and app structure, and
manage.py
commands - Includes optimisation: Memcached, Redis, and the ORM (
prefetch_related
) are just some of the tools employed when the code is refactored, and the Django Debug Toolbar is introduced for profiling
Weaknesses
- No testing: testing isn’t included at all, and this is my biggest criticism. While testing is potentially a huge topic that could fill many books, it would have been helpful to build it into one of the projects. If necessary, I would propose sacrificing the chapter on internationalisation (i18n) to maintain the same length
- Version control: this book isn’t particularly Git-friendly. There is little to no mention of Git, which is understandable, but you won’t always get a logical set of commits (which might be important to you if you plan to reference them in the future)
- Use of JavaScript: some of the JavaScript elements were difficult to troubleshoot. It would have been better to create them as separate
js
orts
files and then import them. I didn’t have time to search for solutions to syntax highlighting beyond djLint, and I did encounter some hurdles when troubleshooting the code - Hosts file: the steps to alter the
hosts
file should not be followed. It is not recommended to modifylocalhost
, as this can cause frustrating network problems. You can actually get by without this, and the book should make that clear
Further Exploration
I would recommend exploring the following topics to complement this book:
Conclusion
This book really lives up to its name; it teaches you Django using four great examples. It won’t teach you version control or testing, but it will allow you to push out applications quickly.
I would recommend this book to anyone to wants to explore Django in more depth, or become more confident and productive with the core of Django’s feature set. Pair this up with some resources on testing (such as unittest and Pytest) for best results.
You can view my versions of the example projects on GitHub (just search for example
).