Guest User

Untitled

a guest
Apr 25th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. request.build_absolute_uri()
  2.  
  3. class SimpleMiddleware(object):
  4. def __init__(self, get_response):
  5. self.get_response = get_response
  6. # One-time configuration and initialization.
  7.  
  8. def __call__(self, request):
  9. # Code to be executed for each request before the view (and later middleware) are called.
  10.  
  11. # sets to show Taiwan or Indo version
  12. # sets the timezone too
  13. http_host = request.META['HTTP_HOST']
  14. if(http_host == 'http://www.xxx.tw'):
  15. request.session['web_to_show'] = settings.TAIWAN
  16. request.session['timezone_to_use'] = settings.TAIWAN_TIMEZONE
  17. else:
  18. request.session['web_to_show'] = settings.INDO
  19. request.session['timezone_to_use'] = settings.INDONESIA_TIMEZONE
  20.  
  21. response = self.get_response(request)
  22.  
  23. # Code to be executed for each request/response after the view is called.
  24.  
  25. return response
  26.  
  27. from django.contrib.sites.shortcuts import get_current_site
  28. domain = get_current_site(None)
Add Comment
Please, Sign In to add comment