middleware that sets site attribute to request object middleware that sets site attribute to request object
from django.utils.deprecation import MiddlewareMixin

from .shortcuts import get_current_site


class CurrentSiteMiddleware(MiddlewareMixin):
    

    def process_request(self, request):
        request.site = get_current_site(request)