<commit_before>from django.utils.functional import SimpleLazyObject
from django.contrib.sites.models import Site, get_current_site

from . import get_building


class CurrentSiteMiddleware(object):

    """Gets current Site based on HTTP HOST (fallback on SITE_ID).

    The site object is added to request.site.
    """

    def get_site(self, request):

        try:<commit_msg>Redirect fix<commit_after>from django.utils.functional import SimpleLazyObject
from django.contrib.sites.models import Site, get_current_site

from . import get_building


class CurrentSiteMiddleware(object):

    """Gets current Site based on HTTP HOST (fallback on SITE_ID).

    The site object is added to request.site.

    This middleware goes after CurrentBuildingMiddleware.
    """

    def get_site(self, request):

        if request.building:
            return request.building.site

        try:
{'fraction_non_alphanumeric': 0.07086614173228346, 'fraction_numerical': 0.0, 'mean_word_length': 3.61139896373057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4815203', 'n_tokens_mistral': 253, 'n_tokens_neox': 238, 'n_words': 79}