Two Scoops of Django: Best Practices for Django 1.5

This book is chock-full of material that will help you with your Django projects.

We’ll introduce you to various tips, tricks, patterns, code snippets, and techniques that we’ve picked up over the years.

This book is great for:

Beginning Django developers.

Developers with intermediate to advanced knowledge of Django who want to improve their Django projects.

This is the final release of the 1.5 book. We have put thousands of hours into writing and revising over 300 pages of concise, example-packed text. Also available is Two Scoops of Django 1.6.

Available from here as an e-book bundle containing PDF, EPUB, and MOBI formats. (Also available on Amazon.com in print format.)

Also available from:

What have people said about Two Scoops of Django?

Make sure you have your favorite project next to you while reading. You’ll be doing some rewriting. ~ Bryan Veloso, GitHubber, PyCon PH Keynote speaker

If I could time travel, the first thing I’d do would be give my younger self a copy of this book, and make him read it. ~ Randall Degges, Passionate Python Hacker

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"

This book should prove to be an amazing resource for any new-to-Django developer that picks it up. ~ Kenneth Love, Creator of "Getting Started with Django"

<3 <3 <3 ~ Jannis Leidel, Django Core Contributor

A single read-through of Two Scoops of Django gave me so many lightbulbs and tips; I had to go back for a second helping. ~ Lynn Root, Red Hat engineer and PyLadies ambassador.

Ha ha, I learned something in the first chapter. Awesome. ~ Zed Shaw, Author of Learn Python the Hard Way.

Two Scoops should provide some food for thought and usable recommendations for anybody using Django regularly. ~ Malcolm Tredinnick, Django Core Contributor

No matter what your skill level is, Two Scoops has solid tips for everyone. ~ Jeff Triplett, Developer at Revsys

This book is pure gold. If you're starting your Django adventure then buy this book. It will help you land your job. If you are experienced Django programmer, then buy this book. You will learn new things and question some other. It is that great. ~ Tomasz Paczkowski, DjangoCon Europe Co-organizer

This is the book I wished had existed and I could have read when I started learning Django. ~ Barry Morrison, Linux systems engineer and Django developer

I find analogies are very helpful for my understanding and the ice cream one is perfect. ~ Wifarley on Hacker News

Two Scoops of Django is by far the best Django book I’ve read. ~ Ben Beecher on Twitter

The writing is clear, concise, and accurate. This might be the best Django book I've read. ~ Jessica Ross

Are there any negatives? Well yes. Only one: I wish I’ve read it earlier! ~ Branko Vukelic

Thanks for writing the book - I learned quite a few new things from it and I have been using Django since 0.92. ~ Phil Davis

What does the book cover?

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

The Optimal Django Setup

Tips and tricks for setting up your computer with Django and important tools 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.

Bottleneck Analysis

Is your project running slow? We cover how to determine where bottlenecks exist and how to fix them.

Advanced Django Form Usage

Daniel gave the DjangoCon 2011 Advanced Django Form Usage talk and is updating it for PyCon 2013. 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.

The Django 1.5 User model

Extend abstract base User classes to store the data you need.

Tons of code examples!

This book is loaded with code examples. We've gone the extra mile to put together great examples for you.

Table of Contents

Here is a snapshot of the table of contents from Two Scoops of Django: Best Practices for Django 1.5.

Chapter 1: Coding Conventions

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: Database/Model Best Practices

Chapter 7: Function- and Class-Based Views

Chapter 8: Best Practices for Class-Based Views

Chapter 9: Common Patterns for Forms

Chapter 10: More Things to Know About Forms

Chapter 11: Building REST APIs in Django

Chapter 12: Templates: Best Practices

Chapter 13: Template Tags and Filters

Chapter 14: Tradeoffs of Replacing Core Components

Chapter 15: Working With the Django Admin

Chapter 16: Dealing with the User Model

Chapter 17: Django’s Secret Sauce: Third-Party Packages

Chapter 18: Testing Chapter of Doom!

Chapter 19: Documentation: Be Obsessed

Chapter 20: Finding and Reducing Bottlenecks

Chapter 21: Security Best Practices

Chapter 22: Logging: What’s It For, Anyway?

Chapter 23: Signals: Use Cases and Avoidance Techniques

Chapter 24: What About Those Random Utilities?

Chapter 25: Deploying Django Projects

Chapter 26: How To Release Your Own Django Packages

Chapter 27: Closing Thoughts

Appendix A: Packages Mentioned in This Book

Appendix B: Troubleshooting

Appendix C: Additional Resources

Acknowledgments

Index

Why We Wrote This Book

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.

Find Any Errors?

Can't Afford the Book?

If you’re struggling with finances and can’t afford it, let us know and we’d be happy to send you a free PDF of this 1.5 edition. Drop us a note at hello@twoscoopspress.org and we’ll try to get it to you within 72 hours.