27.4 Putting It All Together

Custom template tags are incredibly useful, as they allow us to take control of the DTL in a way that was previously unavailable to us. We can control the display of variables using filters, and the power afforded to us by template tags means we can change display, control flow, and almost anything imaginable.

Custom template tags are also an excellent way to circumvent views’ centralized power. Instead of needing a view to give the template context, template tags allow us to reach directly to models (or any other part of the system) to do exactly what we want. When discussing why Django doesn’t adhere to MVC architecture, most developers cite custom template tags as their first example.

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.