6.7 Putting It All Together

When organizing code in Django, many beginners ask, Where do I put this? Experienced developers answer cryptically: use fat models, thin views, and thinner templates. We followed this advice in this chapter. We could have coded URL reversal functionality in the template, but it might cost us extra work down the line. It is far better for us to remove that code and keep it in our models. We are in effect fattening our model in favor of slimming our templates.

The central goal, of course, was not to fatten our models or slim our templates, but to add hyperlink functionality in such a way as to make our life easy in the long run by adhering to DRY. We could only do this because we had a mostly implemented Model-View-Controller ...

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.