class HeaderMixin:
    """
    A mixin to add extra HTTP headers to the response in Django views.

    This mixin allows specifying additional HTTP headers that will be included
    in the response generated by the view. Headers can be defined statically
    by setting the `headers` attribute or dynamically by overriding the
    `get_headers` method.
    """

    headers = {}

    def get_headers(self, request):
        return self.headers

    def dispatch(self, request, *args, **kwargs):
        """
        Overrides the dispatch method to add the specified headers to the response
        before returning it.
        """
        response = super().dispatch(request, *args, **kwargs)
        for key, value in self.get_headers(request).items():
            if key not in response:
                response[key] = value
        return response
