27.1 Introduction

When discussing Model-View-Controller (MVC) architecture (which Django is only very loosely based on, as we saw in Chapter 12: The Big Picture), developers advocate for fat models, thin controllers, and even thinner views. Django follows a similar principle: logic surrounding data should be placed in models as much as possible, while the controller should handle only logic related to rendering webpages. The templates should be limited entirely to displaying content.

At the moment, some of our templates are overly complicated. The way we compute how to display related blog posts is long and complicated. What’s more, our templates are in violation of Don’t Repeat Yourself (DRY) principles in multiple places: most of our forms ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.