All templates that extend from 'base.html' will contain content inside {% block header %} and {% endblock %} if they do not override the block or its ancestors (by deleting part of {% block header %}...{% endblock %} ).
If there are templates that do not apply to base.html , you can put the code in your shared database or use something like an inline tag or inclusion tags
In addition, for the code to work correctly for authenticated users, you need to make sure that there is a user variable in the context: it usually already exists, or you need to enable "django.contrib.auth.context_processors.auth" again if you have it deleted before, check the document
source share