我有 django 项目,其中移动部分 settings.py 配置如下
MIDDLEWARE_CLASSES = (
'site_middleware.SetSiteFromHost',
)
SITE_ID = 1
和 site_middleware.py :
class SetSiteFromHost:
def process_request(self, request):
if mobileBrowser(request):
if request.GET.get('server', False):
request.session['server_mode'] = True
site = 1
elif request.session.get('server_mode') == True:
site = 1
else:
request.session['server_mode'] = False
site = 2
else:
site = 1
settings.SITE_ID = site
错误未显示,但切换不起作用?