Most often, the content that should be shown on a webpage will have to be defined in the view. If this is the content to be shown on every page, it is logical to create a context processor. Another situation is where you need to show additional content such as the latest news or a random quote on some pages; for example, the starting page or the details page of an object. In this case, you can load the necessary content with the {% get_objects %}
template tag, which we will implement in this recipe.
Once again, we will start with the utils
app that should be installed and ready for custom template tags.
An advanced custom template tag consists of a function that parses arguments that are passed to the tag and a Node
class that renders the output of the tag or modifies the template context. Perform the following steps to create the {% get_objects %}
template tag:
First, let's create the function parsing the...