When one uses a template, used by various apps, that requires a specific variable
<a href="{% url 'blog:blog-detail' user_blog %}">My blog</a>
we want to ensure that the template will always be aware of the variable user_blog
. Also, we don't want to hammer the logic in every view.
In such cases, the question popping up is usually within the lines of "How to make a variable available to all templates?" and so we are redirected to Template context processors.
Since what we want is dependent on a user instance, we wouldn't be able to use a context processor for something like this
user_blog = self.request.user.blog
return {'user_blog': user_blog}
because, as noted by Willem Van Onsem
A contextprocessor only passes extra variables to the template render engine, so it returns a dictionary, and does not take any parameters (except for the request).
What do we then do in such cases?