You know those lessons you learn when projects blow up in your face? This book contains several projects worth of such lessons. ~ Lennart Regebro, author of "Porting to Python 3"

One reason why using Django is better than Rails or some Node framework is because of @pydanny and @audreyr's 2 scoops book! What a reference! ~ Lakshman Prasad, senior Python developer, educator, and speaker

What does the book cover?

Two Scoops of Django covers common best practices, including the following:

The Optimal Django Setup

Tips, tricks, and tools for quickly setting up your Django project in the most optimal way.

Django Class-Based Views

We were part of the massive rewrite of Django's official class-based view documentation. In the book we cover the gray area where the docs end and specific use cases begin.

Securing Your Django Projects

Django has a good security record. Help keep it that way by learning how to lock down and secure your projects. Everything in this chapter is approved by third-party security experts.

Bottleneck Analysis

Is your project running slow? We cover how to determine where bottlenecks exist and how to fix them. Learn how to run slow processes behind asynchronous task queues.

Advanced Django Form Usage

Daniel loves Django forms, and has written numerous articles and presentations on them. Gain a deeper understanding of forms through his detailed examples.

Settings and Requirements Files

Manage your settings/dependencies for different environments such that 100% of settings and 0% of secret keys are in version control.

Model Inheritance

We provide everything you need to know about concrete, abstract, and proxy models.

Yummy Queries!

Stabilize your data with transactions, then read it with advanced query tools.

Tons of code examples!

This book is loaded with code examples. We've gone the extra mile to put together great examples for you, and you can access them online.

Table of Contents

Here is the table of contents from Two Scoops of Django: Best Practices for Django 1.8.

Chapter 1: Coding Style

Chapter 2: The Optimal Django Environment Setup

Chapter 3: How to Lay Out Django Projects

Chapter 4: Fundamentals of Django App Design

Chapter 5: Settings and Requirements Files

Chapter 6: Model Best Practices

Chapter 7: Queries and the Database Layer (NEW)

Chapter 8: Function- and Class-Based Views

Chapter 9: Best Practices for Function-Based Views

Chapter 10: Best Practices for Class-Based Views

Chapter 11: Form Fundamentals

Chapter 12: Common Patterns for Forms

Chapter 13: Templates: Best Practices

Chapter 14: Template Tags and Filters

Chapter 15: Django Templates and Jinja2

Chapter 16: Building REST APIs

Chapter 17: Consuming REST APIs

Chapter 18: Tradeoffs of Replacing Core Components

Chapter 19: Working With the Django Admin

Chapter 20: Dealing with the User Model

Chapter 21: Django's Secret Sauce: Third-Party Packages

Chapter 22: Testing Chapter of Doom!

Chapter 23: Documentation: Be Obsessed

Chapter 24: Finding and Reducing Bottlenecks

Chapter 25: Asynchronous Task Queues

Chapter 26: Security Best Practices

Chapter 27: Logging: What's It For, Anyway?

Chapter 28: Signals: Use Cases and Avoidance Techniques

Chapter 29: What About Those Random Utilities?

Chapter 30: Deployment: Platforms as a Service

Chapter 31: Deploying Django Projects

Chapter 32: Continuous Integration

Chapter 33: The Art of Debugging (NEW)

Chapter 34: Where and How to Ask Django Questions

Chapter 35: Closing Thoughts

Appendix A: Packages Mentioned in This Book

Appendix B: Troubleshooting

Appendix C: Additional Resources

Appendix D: Internationalization and Localization

Appendix E: Settings Alternatives

Appendix F: Working with Python 3

Appendix G: Security Settings Reference

Acknowledgments

Index

Why We Wrote This Book Series

After seeing other fellow developers struggle to get past the same sorts of basic hurdles in Django we had to overcome, we realized that much of the Django knowledge that we take for granted is not written down with examples anywhere.

We decided to take everything we know and write it down. Along the way, we learned even more from others and wrote those things down as well.