#30021: Feature request to allow "mixed mode" Sites operation. -------------------------------+-------------------------------------- Reporter: Ira Abbott | Owner: nobody Type: New feature | Status: new Component: contrib.sites | Version: 2.1 Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 1 | Needs documentation: 1 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 -------------------------------+--------------------------------------
Comment (by Ira Abbott): After more tweaking and plugging it in for test: def get_current(self, request=None): """ Return the current Site based on the SITE_ID in the project's settings. If SITE_ID isn't defined, return the site with domain matching request.get_host(). The ``Site`` object is cached the first time it's retrieved from the database. """ from django.conf import settings site_id = getattr(settings, 'SITE_ID', '') mixed_mode = getattr(settings, 'SITE_MIXED_MODE', '') if site_id and not mixed_mode: return self._get_site_by_id(site_id) elif request: return self._get_site_by_request(request) elif site_id and mixed_mode == True: return self._get_site_by_id(site_id) raise ImproperlyConfigured( "You're using the Django \"sites framework\" without having " "set the SITE_ID setting. Create a site in your database and " "set the SITE_ID setting or pass a request to " "Site.objects.get_current() to fix this error." ) -- Ticket URL: <https://code.djangoproject.com/ticket/30021#comment:11> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.c76203417604a0fe6fdc54a7036aea33%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.