Django tutorial: Template Tags vs Context Processors

Jordan P. Raychev
Geek Culture
Published in
6 min readMay 31, 2021

--

I have been working on a personal project for a while and stumble across an interesting point during the build. To put things into context, I wanted to build a site footer that holds additional information to the site content. As probably most of you know footer section is shared across your whole application regardless the page you are on. So in this article I will go over two different ways of building such feature.

Photo by Faisal on Unsplash

For those who never worked with Django I would recommend checking some of my other articles where I explain some basic principles about Django framework. For those who are a bit familiar with Django you probably may know that each template (HTML page) is rendered by a particular view. A Django view is basically a function that takes your web request and return a web response. The response on the other hand consists of a HTML template populated with some context which could be either static or dynamic. Knowing this you may attempt to render a specific context to every view you want to — making a lot of redundant code and that is in conflict with Django’s DRY (Do not Repeat Yourself) principle. A better approach is to use another feature of Django framework known as Template tag or Context Processor. I know that some of more experience Django developers may say that Template tags shouldn’t be used for putting context into a template but what…

--

--

Jordan P. Raychev
Geek Culture

Network, system and software engineer with true passion about technology. Love to read and spend time in nature.