diff --git a/myapp/settings.py b/myapp/settings.py
index a426e203fd0884251b8592ae8cff712e4abf5d78..accdd9d765ff131b8a51174c51d1a3dc79501137 100644
--- a/myapp/settings.py
+++ b/myapp/settings.py
@@ -11,6 +11,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
 """
 
 import os
+import json
+import base64
+from urllib.parse import urlparse
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -118,3 +121,40 @@ USE_TZ = True
 # https://docs.djangoproject.com/en/2.1/howto/static-files/
 
 STATIC_URL = '/static/'
+
+# Import some Platform.sh settings from the environment.
+
+STATIC_ROOT = os.path.join(os.getenv('PLATFORM_APP_DIR'), 'static')
+
+entropy = os.getenv('PLATFORM_PROJECT_ENTROPY')
+if entropy:
+    SECRET_KEY = entropy
+
+routes = os.getenv('PLATFORM_ROUTES')
+if routes:
+    routes = json.loads(base64.b64decode(routes).decode('utf-8'))
+    app_name = os.getenv('PLATFORM_APPLICATION_NAME')
+    for url, route in routes.items():
+        host = urlparse(url).netloc
+        if (host not in ALLOWED_HOSTS and route['type'] == 'upstream'
+                and route['upstream'] == app_name):
+            ALLOWED_HOSTS.append(host)
+
+relationships = os.getenv('PLATFORM_RELATIONSHIPS')
+if relationships:
+    relationships = json.loads(base64.b64decode(relationships).decode('utf-8'))
+    db_settings = relationships['database'][0]
+    DATABASES = {
+        'default': {
+            'ENGINE': 'django.db.backends.postgresql',
+            'NAME': db_settings['path'],
+            'USER': db_settings['username'],
+            'PASSWORD': db_settings['password'],
+            'HOST': db_settings['host'],
+            'PORT': db_settings['port'],
+        },
+        'sqlite': {
+            'ENGINE': 'django.db.backends.sqlite3',
+            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+        }
+    }