Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- request.build_absolute_uri()
- class SimpleMiddleware(object):
- def __init__(self, get_response):
- self.get_response = get_response
- # One-time configuration and initialization.
- def __call__(self, request):
- # Code to be executed for each request before the view (and later middleware) are called.
- # sets to show Taiwan or Indo version
- # sets the timezone too
- http_host = request.META['HTTP_HOST']
- if(http_host == 'http://www.xxx.tw'):
- request.session['web_to_show'] = settings.TAIWAN
- request.session['timezone_to_use'] = settings.TAIWAN_TIMEZONE
- else:
- request.session['web_to_show'] = settings.INDO
- request.session['timezone_to_use'] = settings.INDONESIA_TIMEZONE
- response = self.get_response(request)
- # Code to be executed for each request/response after the view is called.
- return response
- from django.contrib.sites.shortcuts import get_current_site
- domain = get_current_site(None)
Add Comment
Please, Sign In to add comment