Here is the big news I hinted at in my last Pycon talk. I have been working on a book titled “Django Design Patterns and Best Practices”. Most of the early drafts have been reviewed and it is slated for publishing in March.
You can pre-order it here right now! Click here if you like to be notified when it will be published.
Some of the highlights of this book:
- Guides advanced beginners to web application fundamentals and patterns
- Updated for Django 1.7 (upcoming 1.8 features also mentioned)
- Covers the creation of a fun project - a social network for superheroes
- Uses engaging story elements to illustrate real world challenges
- A short read at less than 200 pages
Most Python programmers I know, rarely use a Gang of Four pattern like the Strategy Pattern or the Iterator Pattern. It makes sense, too. After all, they were designed for object-oriented programming languages like C++ and Smalltalk, while Python has better higher-order abstractions. Many of these patterns are not even required in Python.
But while working in Django, we come across patterns at a higher level of abstraction. They could be anything from implementing models to store user profile details or inserting the same set of context variables to multiple views.
When faced with tough deadlines, we might code away until we get a feature working (Coding vs Programming?). But what if we are – as Django’s tagline says – Perfectionists with deadlines? Wouldn’t you prefer a cleaner solution over a kludgy one that just works? Do you see a set of problems enough number of times to expect a generally acceptable solution?
My definition of a Django design pattern is quite broad. It could be any design problem that occurs frequently while working in Django. It could have a confusingly large number of solutions. A pattern will try to illustrate the cleanest solution that can be applied every time the problem occurs.
The creators of Django have beautifully documented many of their design principles like – Don’t Repeat Yourself (DRY), Loose Coupling, Tight Cohesion etc. They help us write better and more idiomatic Django applications. They also guide us in choosing a better design pattern among many alternative approaches.
However, there is a lot of undocumented wisdom that is considered best practice. There is no right or wrong way to design a URL scheme for a website, Django is quite flexible to support even the most esoteric schemes, but there are definitely best practices.
Making high quality Django applications requires you to be constantly updated with current best practices. Every time a release of Django brings a major change like database migrations or custom user models we need to reassess our practices. This book will hopefully be a guide to the latest Django and Python best practices.
Who is it for?
As a speaker, I have met numerous people who would like to learn more about Django. I am constantly amazed by the varied backgrounds they come from. Be it a teacher in Philippines or a stock trader in New Jersey, many are learning Django to build that dream web application.
Many get stuck after learning the brilliant polls tutorial. They are overwhelmed by the number of topics they need to know. Most books expect you to know Database theory, Information architecture, Web design etc. Most people just need to know the essentials and, preferably, in a smaller form.
I hope this book will be useful for beginners and experienced Django developers alike. There should be a focus on fundamentals even for an advanced book. Because you can always build on fundamentals. By the end of the book, you should become a more efficient and pragmatic web developer.
Help a Charity
At the time of conceptualizing the book, I had considered releasing it open source. However, it seemed much more meaningful to donate a part of the book’s royalty to charity. That way, it would not only sustain the writer (and his family) but later would be a powerful motivator to complete the book itself.
I would be donating half of all royalties from this book to recognized charities like Swanthana who focus on children with special needs. So when you buy this book, you know that you would have made a positive impact on a child’s life.
In the next few days I plan to keep you posted on the updates about the book. In the past few months, I have learnt a lot about writing. It is not unlike programming except that the language is a lot more trickier ;) .
Hope to share more details about the writing process soon. There is a lot of excitement coming your way!