Gain your Django Superpowers!

Build maintainable websites with elegant Django design patterns and modern best practices

Available in PDF, Kindle, ePub and Print.

Buy from Amazon Packt

What's Inside

  • Save time by applying design patterns to everyday problems
  • Grasp concepts visually with over two dozen diagrams
  • Explore the area you need from App design to Debugging
  • Build as you read using a project-based approach

What's New?

...Compared to the First Edition

Updated for Django 2.0 and Python 3.6

Now covers Channels 2, Django REST framework, asyncio and Serverless.

Every diagram completely redone in a new visual style

"I highly recommend this book to people who have completed the infamous polls tutorial as it represents a great survey of topics that the beginner would greatly benefit from using in practice."

"I am loving the book. Very interesting and easy to follow method of explaining Django. For me quite a big jump in Django understanding"

"Finishing the book #Django Design #Patterns and #BestPractices write by @arocks, totally recommended awesome book, worth every dollar."

Superbook Project

We will be building Superbook — a social network for superheroes — throughout the book. All code examples will be presented in this fun and engaging theme.

Find the code on Github »

Contents

A chapter-wise breakdown of the book.

  • Chapter 1 , Django and Patterns, helps us understand Django better by telling us why it was created and how it has evolved over time. Then, it introduces design patterns, their importance, and several popular pattern collections.

  • Chapter 2 , Application Design, guides us through the early stages of an application's life cycle, such as gathering requirements and creating mock-ups. We will also see how to break your project into modular apps through our running example—SuperBook.

  • Chapter 3 , Models, gives us insights into how models can be graphically represented, structured using several kinds of patterns and can be later altered using migrations.

  • Chapter 4 , Views and URLs, shows us how function-based views evolved into class-based views with the powerful mixin concept, familiarizes us with useful view patterns, and teaches how short and meaningful URLs are designed.

  • Chapter 5 , Templates, walks us through Django template language constructs, explaining its design choices, suggests how to organize template files, introduces handy template patterns, and points to several ways Bootstrap can be integrated and customized.

  • Chapter 6 , Admin Interface, focuses on how to use Django's brilliant out-of-the box admin interface more effectively and several ways to customize it, from enhancing the models to toggling feature flags.

  • Chapter 7 , Forms, illustrates the often confusing form workflow, different ways of rendering forms, improving a form's appearance using crispy forms, and various applied form patterns.

  • Chapter 8 , Working Asynchronously, tours various asynchronous solutions for the Django developer, from the feature-rich Celery task queues, Python 3's asyncio, to the brand new Channels 2, and compares them for you.

  • Chapter 9 , Creating APIs, explains RESTful API design concepts with practical advice on topics such as versioning, error handling, and design patterns using the Django REST framework.

  • Chapter 10 , Dealing with Legacy Code, tackles common issues with legacy Django projects, such as identifying the right version, locating the files, where to start reading a large code base, and how to enhance it to add new functionality.

  • Chapter 11 , Testing and Debugging, gives us an overview of various testing and debugging tools and techniques, introducing test-driven development, mocking, logging, and debuggers.

  • Chapter 12 , Security, familiarizes you with various web security threats and their counter measures, specifically looking at how Django can protect you. Finally, a handy security checklist reminds you of the commonly overlooked areas.

  • Chapter 13 , Production-Ready, is a crash course in deploying a public-facing application beginning with choosing your webstack, understanding hosting options, and walking through a typical deployment process. We go into the details of monitoring and performance at this stage.

  • Appendix A , Python 2 Versus Python 3, introduces Python 3 to Python 2 developers. Starting off by showing the most relevant differences while working in Django, we move on to the new modules and tools offered in Python 3.

About the Author

Arun Ravindran is an avid speaker and blogger who has been tinkering with Django since 2007 for projects ranging from intranet applications to social networks. He is a long-time open source enthusiast and Python developer. His articles and screencasts have been invaluable to the rapidly growing Django community. He is currently a developer member of the Django Software Foundation. Arun is also a movie buff and loves graphic novels and comics.

Author Arun Ravindran's pic