diff options
author | 2022-01-23 16:38:03 +0100 | |
---|---|---|
committer | 2022-01-23 16:38:03 +0100 | |
commit | 605d9a0266a9a967f051fa244bf1c2d31776c119 (patch) | |
tree | a9f3218e355c8f6a106ba2604334ce8a34823715 /pydis_site/settings.py | |
parent | Link icons belong close together. (diff) | |
parent | Merge pull request #640 from Krish-bhardwaj/main (diff) |
Merge branch 'main' into swfarnsworth/smarter-resources/merge-with-main
Diffstat (limited to 'pydis_site/settings.py')
-rw-r--r-- | pydis_site/settings.py | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/pydis_site/settings.py b/pydis_site/settings.py index da582517..5a8e9be7 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -25,7 +25,8 @@ from pydis_site.constants import GIT_SHA env = environ.Env( DEBUG=(bool, False), SITE_DSN=(str, ""), - BUILDING_DOCKER=(bool, False) + BUILDING_DOCKER=(bool, False), + STATIC_BUILD=(bool, False), ) sentry_sdk.init( @@ -55,22 +56,24 @@ else: ALLOWED_HOSTS = env.list( 'ALLOWED_HOSTS', default=[ + 'www.pythondiscord.com', 'pythondiscord.com', - 'admin.pythondiscord.com', - 'api.pythondiscord.com', - 'staff.pythondiscord.com', - 'pydis-api.default.svc.cluster.local', gethostname(), - gethostbyname(gethostname()) - ] + gethostbyname(gethostname()), + 'site.default.svc.cluster.local', + ], ) SECRET_KEY = env('SECRET_KEY') # Application definition -INSTALLED_APPS = [ +NON_STATIC_APPS = [ 'pydis_site.apps.api', - 'pydis_site.apps.home', 'pydis_site.apps.staff', +] if not env("STATIC_BUILD") else [] + +INSTALLED_APPS = [ + *NON_STATIC_APPS, + 'pydis_site.apps.home', 'pydis_site.apps.resources', 'pydis_site.apps.content', 'pydis_site.apps.events', @@ -84,20 +87,24 @@ INSTALLED_APPS = [ 'django.contrib.sites', 'django.contrib.staticfiles', - 'django_hosts', 'django_filters', 'django_simple_bulma', 'rest_framework', 'rest_framework.authtoken', + + 'django_distill', ] if not env("BUILDING_DOCKER"): INSTALLED_APPS.append("django_prometheus") +NON_STATIC_MIDDLEWARE = [ + 'django_prometheus.middleware.PrometheusBeforeMiddleware', +] if not env("STATIC_BUILD") else [] + # Ensure that Prometheus middlewares are first and last here. MIDDLEWARE = [ - 'django_prometheus.middleware.PrometheusBeforeMiddleware', - 'django_hosts.middleware.HostsRequestMiddleware', + *NON_STATIC_MIDDLEWARE, 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', @@ -108,7 +115,6 @@ MIDDLEWARE = [ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django_hosts.middleware.HostsResponseMiddleware', 'django_prometheus.middleware.PrometheusAfterMiddleware' ] @@ -120,10 +126,6 @@ TEMPLATES = [ 'DIRS': [os.path.join(BASE_DIR, 'pydis_site', 'templates')], 'APP_DIRS': True, 'OPTIONS': { - 'builtins': [ - 'django_hosts.templatetags.hosts_override', - ], - 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', @@ -143,7 +145,7 @@ WSGI_APPLICATION = 'pydis_site.wsgi.application' DATABASES = { 'default': env.db(), 'metricity': env.db('METRICITY_DB_URL'), -} +} if not env("STATIC_BUILD") else {} # Password validation # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators @@ -185,11 +187,6 @@ STATICFILES_FINDERS = [ 'django_simple_bulma.finders.SimpleBulmaFinder', ] -# django-hosts -# https://django-hosts.readthedocs.io/en/latest/ -ROOT_HOSTCONF = 'pydis_site.hosts' -DEFAULT_HOST = 'home' - if DEBUG: PARENT_HOST = env('PARENT_HOST', default='pythondiscord.local:8000') @@ -201,7 +198,7 @@ else: PARENT_HOST = env('PARENT_HOST', default='pythondiscord.com') # Django REST framework -# http://www.django-rest-framework.org +# https://www.django-rest-framework.org REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', |