Created
September 10, 2014 01:37
-
-
Save victorono/29c34db917890c71a0a6 to your computer and use it in GitHub Desktop.
Detect domain and set id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SiteDetectionMiddleware: | |
| def process_request(self, request): | |
| settings.SITE_ID = 1 | |
| host = request.META.get('HTTP_HOST') | |
| if host: | |
| try: | |
| site = Site.objects.get(domain=host) | |
| settings.SITE_ID = site.id | |
| except Site.DoesNotExist: | |
| pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment