2016-06-07 08:26:24 +08:00
|
|
|
from django.utils.deprecation import MiddlewareMixin
|
|
|
|
|
2014-10-01 01:15:59 +08:00
|
|
|
from .shortcuts import get_current_site
|
2013-11-19 04:16:09 +08:00
|
|
|
|
|
|
|
|
2016-06-07 08:26:24 +08:00
|
|
|
class CurrentSiteMiddleware(MiddlewareMixin):
|
2013-11-19 04:16:09 +08:00
|
|
|
"""
|
|
|
|
Middleware that sets `site` attribute to request object.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def process_request(self, request):
|
2014-10-01 01:15:59 +08:00
|
|
|
request.site = get_current_site(request)
|