Create option to use subdomain
This commit is contained in:
parent
41837db827
commit
b049f6eace
3 changed files with 9 additions and 1 deletions
|
@ -90,6 +90,8 @@ celery -A dmoj_celery worker
|
|||
node websocket/daemon.js
|
||||
```
|
||||
|
||||
7. To use subdomain for each organization, go to admin page -> navigation bar -> sites, add domain name (e.g, "localhost:8000"). Then go to add `USE_SUBDOMAIN = True` to local_settings.py.
|
||||
|
||||
## Deploy
|
||||
Most of the steps are similar to Django tutorials. Here are two usual steps:
|
||||
|
||||
|
|
|
@ -469,6 +469,9 @@ MESSAGES_TO_LOAD = 15
|
|||
|
||||
ML_OUTPUT_PATH = None
|
||||
|
||||
# Use subdomain for organizations
|
||||
USE_SUBDOMAIN = False
|
||||
|
||||
try:
|
||||
with open(os.path.join(os.path.dirname(__file__), "local_settings.py")) as f:
|
||||
exec(f.read(), globals())
|
||||
|
|
|
@ -95,10 +95,13 @@ class SubdomainMiddleware(object):
|
|||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
request.organization = None
|
||||
if not settings.USE_SUBDOMAIN:
|
||||
return self.get_response(request)
|
||||
|
||||
domain = request.get_host()
|
||||
site = get_current_site(request).domain
|
||||
subdomain = domain[: len(domain) - len(site)]
|
||||
request.organization = None
|
||||
if len(subdomain) > 1:
|
||||
subdomain = subdomain[:-1]
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue