Is there away to encapsuate the context of a django template in one place?

I have a template file for the header of a website which will be included in all pages, it takes a list as a context and renders items based on that list as follows:

{% for category in categories %}
            <li><a class='text-primary' href=" {% url 'category-url' category.id%}">{{category.name | title}}</a></li>
{% endfor %}

Now my problem is that every view that renders any page in the website needs to pass the categories list in order for the header to work (the header is included in all pages). and thus almost all of my views have this code

    return render(request, ..., 'categories':Category.objects.all())

so is there away to have a code that passes the categories to the header once and just rely on that for every other view?

Back to Top